| 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 |
|
|