export_ascii_data
Description
Export specified data ranges from worksheet to an ASCII file.
Syntax
int export_ascii_data( file * pf, LPCTSTR lpcszWksRange, uint nRSize, int * pR1, int * pR2, uint nCSize, int * pC1, int * pC2, LPCSTR lpcszSep, BOOL bCheckAddQuotes = FALSE, BOOL bLabel = FALSE, int * pAddXCol = NULL, double * pX0 = NULL, double * pXInc = NULL, DWORD dwCntrl = GDAT_FULL_PRECISION, LPCSTR lpcszSubfix = NULL)
Parameters
- pf
- [input] the handle of the destination file
- lpcszWksRange
- [input] the range string including the name of matrix page and the name of matrixsheet
- nRSize
- [input] number of row ranges
- pR1
- [input] buffer containing lower bound of row ranges
- pR2
- [input] buffer containing upper bound of row ranges
- nCSize
- [input] number of column ranges
- pC1
- [input] buffer containing lower bound of column ranges
- pC2
- [input] buffer containing upper bound of column ranges
- lpcszSep
- [input] separator between values in output file
- bCheckAddQuotes
- [input] if export to csv, check to replace CRLF and add double-quotes
- bLabel
- [input] whether to add row label in exported file
- pAddXCol
- [input] if not NULL, contains values indicating whether have sampling interval in each column
- pX0
- [input] sampling interval's start
- pXInc
- [input] sampling interval's increment
- dwCntrl
- [input] control bits, can be GDAT_FULL_PRECISION(get numeric data with full precision) and GDAT_MISSING_AS_DASHDASH(get missing value as '--')
- lpcszSubfix
- [input]
Return
return 0 for success, else return error code. -1 if pf is NULL, -2 if lpcszBook or lpcszSheet or lpcszSep is NULL.
Examples
EX1
#include <oExtFile.h>
void export_ascii_data_ex1()
{
WorksheetPage wksPage;
wksPage.Create("Origin");
Worksheet wks = wksPage.Layers();
Column colA(wks, 0);
Column colB(wks, 1);
vector& vA = colA.GetDataObject();
vA.Data(0.5, 50, 0.5); // assigne data from 1 to 100 to column A
vector& vB = colB.GetDataObject();
vB = vA * 10;
file ff;
if ( !ff.Open("C:\\ExpWksData.txt", file::modeCreate|file::modeWrite) )
return;//fail to open file for write
vector<int> vnR1 = {0, 20};
vector<int> vnR2 = {9, 29};
int nRSize = vnR1.GetSize();
vector<int> vnC1 = {0};
vector<int> vnC2 = {1};
int nCSize = vnC1.GetSize();
string strRange;
wks.GetRangeString(strRange);
LPCSTR lpcszSep = "\t";
BOOL bCheckAddQuotes = FALSE;
BOOL bLabel = FALSE;
int nRet = export_ascii_data(&ff, strRange, nRSize, vnR1, vnR2, nCSize, vnC1, vnC2, lpcszSep, bCheckAddQuotes, bLabel);
if ( nRet == 0 )
printf("Export ASCII file successfully!");
return;
}
Remark
See Also
header to Included
oExtFile.h
Reference
|