OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis     
 
Skip Navigation Links
All BooksExpand All Books
OrglabExpand Orglab

1 Orglab

Introduction

The Orglab files are provided for the purpose of creating custom applications that can read and write Origin project (.opj) and window (.ogg, .ogw and .ogm) files. Your custom application will communicate with Orglab using COM.

While Orglab's COM interface appears to be the same as Origin's COM interface it is important to understand that Orglab is not a replacement for Origin and not all of Orglab's COM methods and properties will behave the same as Origin's.

Additionally, Orglab and Origin/OriginPro can be installed and running on the same computer as the Orglab DLL is not dependent upon any Origin/OriginPro DLLs.

The Orglab files may not be used in an application that competes with OriginLab Corporation's own software products. This includes, but is not limited to, Origin, OriginPro, and any of its modules. Use of Orglab for any other purposes without the express written permission of OriginLab Corporation is prohibited.

Read the Orglab End-User License Agreement for full details.

Download

There are 32 and 64 bit versions of Orglab. Both versions are distributed in a .zip file. You can unzip the files to a folder of your choice. Each contains a bin folder. The files in the bin folder can be distributed freely with your custom application.

Download the latest Orglab release from Orglab Download.

Installation

Before you can register the Orglab DLL with Windows, your machine must have the Microsoft Visual C++ Redistributable for Visual Studio 2012 installed. If you do not have this package installed on your machine, you can obtain the files here. Note that there are two versions:


Once you've run the MS EXE, proceed to extract the Orglab zip file. After the files are extracted from the .zip file you need to register the Orglab DLL with Windows before you can use it with your application.

  • Click the Windows Start button.
  • Enter 'cmd' into the Search box.
  • Locate 'cmd.exe' in the found Programs list.
  • Right-click on 'cmd.exe' and choose 'Run as administrator'.
  • In the window that opens enter the following command and press Enter:
    • regsvr32 "<full path and name of the Orglab DLL>"
  • A message box should appear letting you the registration succeeded.

Examples

The following examples demonstrate uses for Orglab.

For more examples of communicating with Orglab, please refer to the Origin COM Examples.

A popular example demonstrates how to read and write an OGW file: Accessing OGW

C#

EX1

// Be sure to add OriginLab Orglab8 to your project's References
using Origin;

static void Main(string[] args)
{
	object Default = System.Type.Missing;

	Origin.Application originApp = new Origin.Application();

	originApp.NewProject();

	string strPageName = originApp.CreatePage
                     ((int)Origin.PAGETYPES.OPT_WORKSHEET, Default, "", 2);

	originApp.Save("C:\\CreatedProject.opj");

	originApp.Exit();
}

EX2

// Create, Save, and Load Project
static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
 
    // Create and Save a Project with Only One Workbook
    oApp.NewProject();
    oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\OneWorkbook.opj");
 
    // Load a Project, Add a Workbook, and Save As Another Project
    oApp.NewProject();
    oApp.Load(System.IO.Directory.GetCurrentDirectory() + @"\OneWorkbook.opj");
    oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\TwoWorkbooks.opj");
 
    oApp.Exit();
}

EX3

// Create Worksheet and Send Data to It
static void Main(string[] args)
{
    // New Origin Project
    Origin.Application oApp = new Origin.Application();
    oApp.NewProject();
 
    // Two Columns of Data: y = sin(x), x in [0, 10.0]
    double[,] data = new double[101, 2];
    for (int i = 0; i <= 100; i++)
    {
        data[i, 0] = i / 10.0;
        data[i, 1] = Math.Sin(data[i, 0]);
    }
 
    // Create Worksheet
    string wpname;
    wpname = oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    Origin.Worksheet wks = oApp.FindWorksheet(wpname);
 
    // Send Data to Worksheet
    wks.SetData(data);
 
    // Set First Column as X
    wks.Columns[0].Type = Origin.COLTYPES.COLTYPE_X;
 
    //Save As .OPJ File and Exit
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\SendDataToNewWorksheet.opj");
    oApp.Exit();
}

EX4

// Create Matrix Page and Send Data to It
static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
    oApp.NewProject();
    double[,] data = new double[100, 100];
    for (int i = 0; i < 100; i++)
        for (int j = 0; j < 100; j++)
            data[i, j] = i * j;
 
    // Create Matrix Page
    string mpname = oApp.CreatePage((int)Origin.PAGETYPES.OPT_MATRIX);
    Origin.MatrixPage mp = oApp.FindMatrixSheet(mpname).Parent;
 
    // Number of Matrix Sheets: 3
    while (mp.Layers.Count < 3)
        mp.Layers.Add();
 
    foreach (Origin.MatrixSheet msht in mp.Layers)
    {
        msht.Name = "MSheet" + msht.Index.ToString();
 
        // Number of Matrix Object per Matrix Sheet: 4
        msht.Mats = 4;
 
        // Dimension: 100x100
        msht.Cols = 100;
        msht.Rows = 100;
 
        // Send Data to Matrix Object
        foreach (Origin.MatrixObject mo in msht.MatrixObjects)
            mo.SetData(data);
    }
 
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\MatrixPage.opj");
    oApp.Exit();
}

EX5

// Get Data From Worksheet, Column, and Matrix Object

// Suppose that there are at least two sheets in Book1,
// and at least one matrix object in [MBook1]MSheet1!.
// Assume there is no graph page with data plot existing 
static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
 
    // Make sure no graph page with data plot exists before loading opj
    oApp.Load(System.IO.Directory.GetCurrentDirectory() + @"\GetDataFromOPJ.opj");
     
    // Current Layer of Book1 or MBook1
    Origin.Worksheet wks = oApp.FindWorksheet("Book1");
    Origin.MatrixSheet msht = oApp.FindMatrixSheet("MBook1");
     
    // Data in [Book1]1
    object wksData = wks.Parent.Layers[0].GetData(0, 0, -1, -1, Origin.ARRAYDATAFORMAT.ARRAY1D_NUMERIC);
     
    // Data in [Book1]2!1
    object colData = wks.Parent.Layers[1].Columns[0].GetData(Origin.ARRAYDATAFORMAT.ARRAY1D_STR, 0, -1);
     
    // Data in [MBook1]1!1
    object moData = msht.MatrixObjects[0].GetData(0, 0, -1, -1, Origin.ARRAYDATAFORMAT.ARRAY2D_NUMERIC);
 
    oApp.Exit();
}

EX6

// Custom Column Label Row
static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
    oApp.NewProject();
 
    // 1. Create Worksheet
    Origin.Worksheet wks;
    string wksName = oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    wks = oApp.FindWorksheet(wksName);
    wks.Cols = 1;
    wks.Rows = 32;
 
    // 2. Show Label Rows: 'Long Name', 'Units', 'Comments', 'Sample Rate', and 2 'Parameters'
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_LONG_NAME, true);
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_UNIT, true);
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_COMMENT, true);
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_SAMPLE_RATE, true);
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_PARAM, true);
    wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_PARAM + 1, true);
 
    // 3. Set Label Rows
    wks.Columns[0].LongName = "Long Name";
    wks.Columns[0].Units = "Units";
    wks.Columns[0].Comments = "Comments";
    wks.Columns[0].Parameter[0] = "Parameter 1";
    wks.Columns[0].Parameter[1] = "Parameter 2";
 
    // 4. Even Sampling
    wks.Columns[0].SetEvenSampling(0.0, 0.1);
 
    // 5. Data
    double[] data = new double[32];
    for (int i = 0; i < 32; i++)
        data[i] = i / 5.0;
    wks.Columns[0].SetData(data);
 
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\ColumLabelRows.opj");
    oApp.Exit();
}

EX7

// Custom Column Display Format
static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
    oApp.NewProject();
 
    double[,] data = new double[32, 3];
    for (int i = 0; i < 32; i++)
    {
        data[i, 0] = i / 10.0;
        data[i, 1] = Math.Cos(i / 10.0);
        data[i, 2] = Math.Sin(i / 10.0);
    }
 
    string wpname = oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    Origin.Worksheet wks = oApp.FindWorksheet(wpname);
    wks.SetData(data);
 
    // Display: Scientific 1E3
    wks.Columns[0].DisplayFormat = 1;
 
    // Digits: Set Decimal Places = 6
    wks.Columns[1].DigitMode = Origin.DIGITMOD.DIGITMODE_DECIMAL_DIGITS;
    wks.Columns[1].Digits = 6;
 
    // Digits: Significant Digits = 6
    wks.Columns[2].DigitMode = Origin.DIGITMOD.DIGITMODE_SIGNIFICANT_DIGITS;
    wks.Columns[2].Digits = 6;
 
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\NumericFormat.opj");
    oApp.Exit();
}

EX8

// Meta Data in Organizer of Workbook
using System.Xml;

static void Main(string[] args)
{
    Origin.Application oApp = new Origin.Application();
    oApp.NewProject();
 
    // Meta Data
    XmlDocument xmlDoc = new XmlDocument();
    XmlNode Node;
    XmlElement topXML, Element;
    topXML = xmlDoc.CreateElement("data");
    Node = xmlDoc.AppendChild(topXML);
    Node = Node.AppendChild(xmlDoc.CreateElement("Instrument"));
    Element = xmlDoc.CreateElement("SerialNumber");
    Element.InnerText = "EQR-23456";
    Node = Node.AppendChild(Element);
    Element = xmlDoc.CreateElement("UsageCount");
    Element.InnerText = "2345";
    Node = Node.ParentNode.AppendChild(Element);
 
    string strXML = topXML.OuterXml;
 
    // Meta Data in a Workbook
    string wpname = oApp.CreatePage((int)Origin.PAGETYPES.OPT_WORKSHEET);
    Origin.Worksheet wks = oApp.FindWorksheet(wpname);
    wks.SetMetaData(strXML, "MetaData", true);
 
    oApp.Save(System.IO.Directory.GetCurrentDirectory() + @"\MetaData.opj");
    oApp.Exit();
}
 

© OriginLab Corporation. All rights reserved.