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
 LabTalk Forum
 Looping over worksheets

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
nicolas777 Posted - 03/26/2010 : 3:57:52 PM
Ok, my data workbook contains 30 worksheets each with 32 columns.
I would like to apply a function on each column of each worksheet. I want the output of this function to be placed in another file in the corresponding worksheet and the corresponding column.
I know how to loop over a column but I don't know how to loop over a worksheet.
I am aware of the doc -e LB function but it doesn't fit the need.
To loop over columns, you increment the column number by using wcol.
Is there a corresponding function for worksheets ?

Thanks

Nicolas
3   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 03/29/2010 : 10:22:40 AM
Just wanted to add this:

// Worksheets are layers in the Workbook (Page Object)
for( laynum = 1 ; laynum <= page.nlayers ; laynum++ )
{
page.active = laynum; // Set the Sheet/Layer as active
ty layer.name$; // Demonstrate next sheet is now active
}
nicolas777 Posted - 03/29/2010 : 09:55:58 AM
Thanks for the answer.
I finally found a way to do it by using doc -e LB.
I'm using the name of the worksheet as an "incremental" variable.

doc -e LB
{
string ss$=wks.name$;

then I perform my operation on every column of the considered worksheet using a for loop and store the final result in a worksheet of the same name but in a different workbook.

N.
rlewis Posted - 03/28/2010 : 03:47:50 AM
This may be a bit tricky with LabTalk.
However If you are willing to try OriginC, you can use code such as ..

void ProcessWorkBook()
{
	WorksheetPage wP=Project.Pages(-1);
	if(wP.IsValid()==true)
	{
		foreach (Layer Lay in wP.Layers)
		{
			Worksheet Wks(Lay);
			if(Wks.IsValid()==true)
			{
				foreach (Column wCol in Wks.Columns)
				{
					// Do Something to the Columns 
				}
			}
		}
	}
}



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