The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Add New Sheet and Rename

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Thomas83 Posted - 05/27/2013 : 05:08:01 AM
Hi.
I want to import files that are numbered in ascending order (e.g. file001, file002, ...). Files with odd numbers should be imported to the first worksheet, files with even numbers to the second worksheet. Worksheet 1 and 2 should be renamed after the import (e.g. "data1", "data2"). The code below imports files with odd numbers at first and than files with even numbers but in the same worksheet. I donīt know how to create and rename a second worksheet to import files with even numbers. Can anyone help me please? The code is as follows:


void importfolder()
{
string strPath = "C:\\TEST\\";
StringArray saFiles;
FindFiles(saFiles, strPath, "*.txt");
if( saFiles.GetSize() < 1 )
return;

Worksheet wks = Project.ActiveLayer();
ASCIMP ai;
//Import files with odd numbers

AscImpReadFileStruct(strPath + saFiles[1], &ai);

ai.iMode = ASCIMP_MODE_APPEND_COLS;
ai.iHeaderLines = 7;
ai.iSubHeaderLines = 0;
ai.iRenameCols = 0;
ai.iPartial = 1;
ai.iPartialC1 = 4;
ai.iPartialC2 = 4;
ai.iPartialR1 = 0;
ai.iPartialR2 = 1000;
ai.iDelimited = 1;
ai.iDelimiter = ASCIMP_DELIM_DEMICOLON;
ai.nNumSep = NF_IS_EUROPEAN;
for(int j = 0; j < (saFiles.GetSize())/2; j++ )
wks.ImportASCII(strPath + saFiles[2*j+1], ai);

//Import files with even numbers
//I want to import these files to a new sheet. how?
AscImpReadFileStruct(strPath + saFiles[0], &ai);

ai.iMode = ASCIMP_MODE_APPEND_COLS;
ai.iHeaderLines = 7;
ai.iSubHeaderLines = 0;
ai.iRenameCols = 0;
ai.iPartial = 1;
ai.iPartialC1 = 4;
ai.iPartialC2 = 4;
ai.iPartialR1 = 0;
ai.iPartialR2 = 1000;
ai.iDelimited = 1;
ai.iDelimiter = ASCIMP_DELIM_DEMICOLON;
ai.nNumSep = NF_IS_EUROPEAN;
for(int i = 0; i < (saFiles.GetSize())/2; i++ )
wks.ImportASCII(strPath + saFiles[2*i], ai);

}

Thanks in advance.

PS: I just started programming in Origin.
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 05/29/2013 : 10:18:45 PM
Hi,

In your code, you are using the same worksheet for importing both odd and even files. So, in such way, of course it will import both add and even files into the same worksheet.

To add a new worksheet, see AddLayer method.
To rename the worksheet, see SetName method.

Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000