1.5.3.3 Converting Matrix to Worksheet

You may need to re-organize your data by converting from matrix to worksheet, or vice versa, for certain analysis or graphing needs. This page provides information and examples of converting matrix to worksheet, and please refer to Converting Worksheet to Matrix for the "vice versa" case.

Matrix to Worksheet

To convert a matrix object data to worksheet, you can firstly get the data in matrix object out to a data matrix, and then use the CopyTo method defined in class.

Here is the example on how to convert the whole matrix object directly into worksheet.

// Convert the active matrix object's data into a newly created worksheet directly, 
// without tranposing, and with setting the column type the same as matrix
MatrixLayer ml = Project.ActiveLayer();  // Active matrixsheet
MatrixObject mo = ml.MatrixObjects(0);  // Get the first matrix object
matrixbase &mb = mo.GetDataObject();  // Get the data from matrix object
Worksheet wks;
wks.Create("Origin");  // Create a new worksheet
mb.CopyTo(wks, 0, 0, -1, -1, 0, 0, FALSE, TRUE);  // Convert the data to worksheet