1.1.2 Reading OPJ Files

C#

public void LoadData()
{
    string strPathName = "C:\\Users\\developer.MICROCAL\\Desktop\\Test_DataType.opj";
    int Colsize;
    int ii, jj, kk = 0;

    Origin.Application org = new Origin.Application();
    org.Load(strPathName, System.Type.Missing);

    for (ii = 0; ii < org.WorksheetPages.Count; ii++)
    { 
        Origin.WorksheetPage orgWkbk = org.WorksheetPages[ii];
        textBox.Text = textBox.Text + (ii + 1).ToString() + ". Book" + (ii + 1).ToString() + "\r\n";
        
        for (jj = 0; jj < orgWkbk.Layers.Count; jj++)
        {
            Origin.Worksheet orgWks = (Origin.Worksheet)orgWkbk.Layers[jj];
            textBox.Text = textBox.Text + "  " + (jj + 1).ToString() + ". Sheet" + (jj + 1).ToString() + "\r\n";

            for (kk = 0; kk < orgWks.Columns.Count; kk++)
            {
                Origin.Column orgCol = orgWks.Columns[kk];
                object[,] Col = orgCol.GetData(0, System.Type.Missing, Origin.ARRAYDATAFORMAT.ARRAY2D_ORIGIN_TEXT_FULL_PRECESSION) as object[,];
                Colsize = Col.GetUpperBound(1);
                textBox.Text = textBox.Text + "---Col(" + (kk + 1).ToString() + "), Size=" + Colsize.ToString() + ", DataFormat=" + orgCol.DataFormat.ToString() + "\r\n";
                textBox.Text = textBox.Text + "   Cell[1]= " + Col[1, 1].ToString() + ", Cell[" + Colsize.ToString() + "]= " + Col[Colsize, 1].ToString() + "\r\n";
            }
        }
    }
}