Following code will work if each block has the same number of text and data lines. See OC_types.h for a full list of ascimp properties.
void ImportAsciiBlocks(int nTextLines, int nDataLines)
{
ASCIMP ascimp;
string strFile = GetOpenBox("*.txt");
int BlockSize = nTextLines + nDataLines;
if(AscImpReadFileStruct(strFile,&ascimp)!=0)
{
out_str("cannot read ascii file");
return;
}
ascimp.iHeaderLines = 0;
ascimp.iSubHeaderLines = 0;
ascimp.iAutoSubHeaderLines = 0;
ascimp.iRenameCols = 0;
ascimp.iRenameWks = 0;
ascimp.iPartial = 1;
ascimp.iPartialC1 = 0;
ascimp.iPartialC2 = 1;
int i;
Worksheet wks;
do
{
wks.Create();
ascimp.iPartialR1 = i*BlockSize + nTextLines;
ascimp.iPartialR2 = (i + 1)*BlockSize - 1;
i++;
} while ( !wks.ImportASCII(strFile, ascimp) );
wks.Destroy(); // last wks will be empty
}
Mike Buess
Origin WebRing Member
Edited by - Mike Buess on 09/15/2006 4:13:34 PM