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
 Forum for Origin C
 How can I access worksheet in subfolder
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ydjang

S. Korea
Posts

Posted - 06/19/2013 :  9:57:48 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):8.1
Operating System:Windows 7

I would like to manipulate the worksheet data with origin C code.
I want that my OriginC code affects to all worksheets only in the specific subfolder.
How do I do it?

For example, there are two subforlders named "folder1" and "folder2".
I would like to control all the worksheets in the "folder1" not "folder2"

Please help me out.

Penn

China
644 Posts

Posted - 06/20/2013 :  05:36:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use the Pages collection to get all the pages in the specified folder, and then figure out those pages that are workbooks by GetType method, and then get the worksheets in the workbook by Layers collection. See the following example.

void worksheets_folder()
{
	Folder fld("/folder1/");  // folder1 under the root folder
	if(!fld)
		return;
	
	foreach(PageBase page in fld.Pages)  // all pages in folder1
	{
		if(page.GetType() == EXIST_WKS)  // if the page is workbook
		{
			WorksheetPage wp(page);  // worksheet page (workbook)
			int nWks = wp.Layers.Count();  // number of worksheets in workbook
			for(int ii = 0; ii < nWks; ii++)
			{
				Worksheet wks = wp.Layers(ii);  // worksheet
				out_str("Worksheet: " + wks.GetName() + " in " + wp.GetName() + " Workbook");  // output worksheet name
			}
		}
	}
}


Penn
Go to Top of Page

ydjang

S. Korea
Posts

Posted - 06/23/2013 :  10:08:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks alot, mate.
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