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 matrix book has the same data structure level with WorksheetPage in Origin, both are windows. So, they contain lots of similar operations.

Workbook-like Operations

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

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

    You can also access a matrix book 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 matrix book
        out_str(matPg.GetName()); // output matrix book name

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

    MatrixPage matPg("MBook1");
    if(matPg) // if there is a matrix book named "MBook1"
        matPg.SetName("MyBook1"); // rename the matrix book
  4. Save Matrix Book
    The methods SaveToFile will be used for saving matrix book as *.ogm file.
    MatrixPage matPg("MBook1");
    // Save matrix book as OGM file
    bool bRet1 = matPg.SaveToFile("D:\\" + matPg.GetName() + ".ogm");
  5. Show or Hide Matrix Book
    This is the same as workbook's show and hide by using the Show property derived from OriginObject class.
  6. Activate Matrix Book
    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 matrix book
  7. Delete Matrix Book
    The Destroy method can also be used to destroy (delete) a matrix book.
    MatrixPage matPg;
    matPg = Project.MatrixPages.Item(0); // get first matrix book in project
    if( matPg ) // if there is a matrix book
        matPg.Destroy(); // delete the matrix book
  8. Clone/Duplicate Matrix Book
    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 Matrix Book
    To handle with matrix book'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