2.1.13.3 export_matrix_ascii_data
Description
Export data from matrix to an ASCII file.
Syntax
int export_matrix_ascii_data( file * pf, LPCTSTR lpcszWksRange, uint nRSize, uint nCSize, LPCSTR lpcszSep, StringArray * vsXCoorid = NULL, StringArray * vsYCoorid = NULL, DWORD dwCntrl = GDAT_FULL_PRECISION )
Parameters
- pf
- [input] the handle of the destination file
- lpcszWksRange
- [input] the range string including name of the matrix page and name of matrix layer
- nRSize
- [input] number of rows to export
- nCSize
- [input] numoer of columns to export
- lpcszSep
- [input] separator between values in output file
- vsXCoorid
- [input] optional, if not NULL, contains all column labels
- vsYCoorid
- [input] optional, if not NULL, contains all row labels
- dwCntrl
- [input] control bits, can be GDAT_FULL_PRECISION(get numeric data with full precision) and GDAT_MISSING_AS_DASHDASH(get missing value as '--')
Return
return 0 is success, else return minus value for failure.
Examples
EX1
#include <oExtFile.h>
void export_matrix_ascii_data_ex1()
{
MatrixLayer ml = Project.ActiveLayer();
if( ml )
{
file ff;
if ( !ff.Open("C:\\ExpMatData.txt", file::modeCreate|file::modeWrite) )
return; //fail to open file for write
string strRange;
ml.GetRangeString(strRange);
LPCSTR lpcszSep = "\t";
vector<string> vXLabels, vYLabels; // empty means no label
DWORD dwCntrl = GDAT_FULL_PRECISION | GDAT_MISSING_AS_DASHDASH;
int nErr = export_matrix_ascii_data(&ff, strRange, ml.GetNumRows(), ml.GetNumCols(), lpcszSep, &vXLabels, &vYLabels, dwCntrl);
if ( nErr == 0 )
printf("Export ASCII file successfully!");
}
}
Remark
See Also
Header to Included
oExtFile.h
Reference
|