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 to add column to newly created sheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ahlers01

Germany
Posts

Posted - 05/26/2010 :  12:33:28 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.0 Service Release 5
Operating System: Win XP

Hi,

I'm a beginner in Origin and I'm stuck with what seems to be a simple operation:

I create, in an existing Book, an additional Sheet, and then I try to add a column to that new sheet:

WorksheetPage wpData = wksData.GetPage();
wpData.AddLayer("Sheet2");
wksData.AddCol();

Before I run the code the book contains only Sheet1, after I run it it contains Sheet1 and Sheet2, but the new column is added to Sheet1 (which is the topmost).

Obviously I have somehow to make Sheet2 topmost or active before calling AddCol(), but I have no idea how to do that. (And Origin's help files didn't give me any clue)

Thanks for your help!

Penn

China
644 Posts

Posted - 05/26/2010 :  01:33:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I guess that the variable wksData in your code is for Sheet1. And then you try to add a new column to Sheet2 by using this line wksData.AddCol();. Of course it will not add the new created column to Sheet2, because the AddCol() method is called by variable wksData, which is for Sheet1.

To add a new column to Sheet2, you should use the variable which is for Sheet2. Please try the following code.

WorksheetPage wpData = wksData.GetPage();  // get Sheet1's page
wpData.AddLayer("Sheet2");  // add one more sheet to page, named Sheet2
Worksheet wksData2 = wpData.Layers("Sheet2");  // get Sheet2
wksData2.AddCol();  // add a new column to Sheet2


Penn
Go to Top of Page

ahlers01

Germany
Posts

Posted - 05/26/2010 :  2:00:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn.

thanks for your extremely quick reply! I love timezones!
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