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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Looping over worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

nicolas777

4 Posts

Posted - 03/26/2010 :  3:57:52 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

rlewis

Canada
253 Posts

Posted - 03/28/2010 :  03:47:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 
				}
			}
		}
	}
}


Go to Top of Page

nicolas777

4 Posts

Posted - 03/29/2010 :  09:55:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

greg

USA
1378 Posts

Posted - 03/29/2010 :  10:22:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
}
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000