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
 Sort worksheets in subfolder for foreach

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
oconnor Posted - 11/22/2004 : 10:17:08 AM
Hi,

I have a series of worksheets titled pbBLOCK01,pbBLOCK02, pbBLOCK03 etc. When I use foreach to go through this collection of worksheets to get the name using:

foreach (PageBase pb in Pages)
{
Worksheet wks(pb.GetName());
string bName=pb.GetName();
printf("Worksheet %s", bName);
}

The list I get doesn't always seem to be sorted by the numerical sorting (ie. pBLOCK01 before pBLOCK02 before pBLOCK03 ...). Every now and then pBLOCK98 shows up before pBLOCK01. The order in which I process these worksheets in the collection is important, so is there anyway to sort the worksheets or instruct foreach to read them in the right order or sort the collection using the last two numbers of the name as an index?

Cheers,

Rod.
2   L A T E S T    R E P L I E S    (Newest First)
hajo Posted - 11/22/2004 : 1:29:12 PM
Hello, Rod

I use a similar sollution as Mike in his posting before.

The only thing is, that I fill the globally definded StringArray sa by creating the worksheets during reading in the data - I create always a worksheet named by Origin itself ("DataXX"). After that I rename it to my needs like "pbBLOCK_NUMBER" with my own numbering system. After renaming the worksheet to its final name I store the name in the StringArray sa to keep tracked to the newly created pages.

Working on these imported worksheets is done in the same way as suggested by Mike.

Hope that helps

Hajo

--
Dipl.-Ing. Hans-Joerg Koch
SiemensVDO Automotive,
Regensburg, Germany
Mike Buess Posted - 11/22/2004 : 11:41:08 AM
Hi Rod,

This should work...

StringArray sa;
string bName;
foreach (PageBase pb in Project.Pages)
{
bName = pb.GetName();
Worksheet wks(bName);
if( wks.IsValid() )
{
sa.Add(bName);
}
}
sa.Sort();
for(int i=0;i<sa.GetSize();i++)
{
printf("Worksheet %s",sa[i];
}

Mike Buess
Origin WebRing Member

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