1.5.1 Base Matrix Book Operation

The Origin C MatrixPage class provides methods and properties common to Origin matrix books. This class is derived from Page class, from which it inherits its methods and properties. And matrixbook has the same data structure level with WorksheetPage in Origin, both are windows. So, they contain lots of similar operations.

Workbook-like Operations

Both matrixbook and workbook are windows, and they share lots of similar operations, and the Basic Workbook Operation chapter can be referred to.

  1. Create New MatrixBook
    The same Create method is used.
    MatrixPage matPg;
    matPg.Create("Origin"); // create a matrixbook using the Origin template
  2. Open Matrixbook
    The difference to open a matrixbook by Open method is that the extension of a matrixbook is ogm.
  3. Access Matrixbook
    There are multiple ways to access an existing matrixbook and the methods used are the same as workbooks. The Project class contains a collection of all the matrixbooks in the project. The following example shows how to loop through them.
    foreach(MatrixPage matPg in Project.MatrixPages)
        out_str(matPg.GetName()); // output matrixbook name

    You can also access a matrixbook by passing its index to the Item method of the Collection class.

    MatrixPage matPg;
    matPg = Project.MatrixPages.Item(2);
    if(matPg) // if there is a 3rd matrixbook
        out_str(matPg.GetName()); // output matrixbook name

    If the matrixbook name is known, this matrixbook can be accessed by passing its name to the class constructor.

    MatrixPage matPg("MBook1");
    if(matPg) // if there is a matrixbook named "MBook1"
        matPg.SetName("MyBook1"); // rename the matrixbook
  4. Save Matrixbook
    The methods SaveToFile will be used for saving matrixbook as *.ogm file.
    MatrixPage matPg("MBook1");
    // Save matrixbook as OGM file
    bool bRet1 = matPg.SaveToFile("D:\\" + matPg.GetName() + ".ogm");
  5. Show or Hide Matrixbook
    This is the same as workbook's show and hide by using the Show property derived from OriginObject class.
  6. Activate Matrixbook
    To activate a workbook, the method SetShow can be used by passing parameter of value PAGE_ACTIVATE, which is the same as to activate a workbook.
    MatrixPage matPg("MBook1");
    matPg.SetShow(PAGE_ACTIVATE);  // Activate the matrixbook
  7. Delete Matrixbook
    The Destroy method can also be used to destroy (delete) a matrixbook.
    MatrixPage matPg;
    matPg = Project.MatrixPages.Item(0); // get first matrixbook in project
    if( matPg ) // if there is a matrixbook
        matPg.Destroy(); // delete the matrixbook
  8. Clone/Duplicate Matrixbook
    The Clone method is also used to clone the matrix page.
    // Duplicate "MBook1" window with data and style 
    // Before calling make sure these windows exist
    MatrixPage matPage("MBook1");
    MatrixPage matPage1 = matPage.Clone();
  9. Name and Label Matrixbook
    To handle with matrixbook's short name, Long Name and Comments, Origin C provides the same ways as handling workbook's, including the inherited methods SetName, SetLongName, SetComments, and Label property.

Show Image Thumbnails

To show or hide image thumbnails, the method MatrixPage::ShowImageThumbnails is available.

MatrixPage mp("tangent");
mp.ShowImageThumbnails(true);  // Pass true to make thumbnail visible