An Origin Matrix can be exported to an ASCII data file or an image file.
The following example shows how to export ASCII data from the active matrix window to a *.txt file. You need to add #include <oExtFile.h> for the export_matrix_ascii_data function.
file ff; if ( !ff.Open("C:\\ExpMatData.txt", file::modeCreate|file::modeWrite) ) return; //fail to open file for write string strRange; MatrixLayer ml = Project.ActiveLayer(); ml.GetRangeString(strRange); LPCSTR lpcszSep = "\t"; vector<string> vXLabels, vYLabels; // empty means no label DWORD dwCntrl = GDAT_FULL_PRECISION | GDAT_MISSING_AS_DASHDASH; // return 0 for no error int nErr = export_matrix_ascii_data(&ff, strRange, ml.GetNumRows(), ml.GetNumCols(), lpcszSep, &vXLabels, &vYLabels, dwCntrl);
The following example shows how to export a matrix to an image file.
Prior to running the following example, the image_utils.c file need to be loaded and compiled. This can be done from script with the following command or just add this file to your workspace.
run.LoadOC(Originlab\image_utils.c);
And need to add #include <image_utils.h> for the export_Matrix_to_image function.
MatrixLayer ml = Project.ActiveLayer(); MatrixObject mo = ml.MatrixObjects(); export_Matrix_to_image("c:\\matrixImg.jpg", "jpg", mo);