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
 Forum for Origin C
 Help manipulating worksheet columns

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
cyantist Posted - 02/23/2010 : 08:25:13 AM
Origin Ver. and Service Release (Select Help-->About Origin): 7.5
Operating System: Windows XP

I'd like to automate the following task and would need some help:

I need to move specific columns from 1 worksheet to new (created or existing)worksheets. For example, if in the main worksheet, I have 5 columns, I'd like to distribute each of the 5 columns into designated columns in separate worksheets, thereby creating 5 new worksheets. I will have more than 1 column from the main worksheet that needs to be distributed and copied amongst the newly created worksheets, i.e., each newly created worksheet will have several columns of data copied from the main worksheet.

In summary:

Need to move Columns ABCXYZ in Main Worksheet to --

Col A and Col X --> New Worksheet 1
Col B and Col Y --> New Worksheet 2
Col C and Col Z --> New Worksheet 3

Thanks in advance for your kind help.
3   L A T E S T    R E P L I E S    (Newest First)
arsk Posted - 01/22/2011 : 05:53:16 AM
Hi Treenode, I must also say thanks to you because you have helped me also in a way when you posted this answer for Cyantist. I was also having great trouble in solving it. But your answer was a life saver for me. Thanks a lot again for your kind help.

Hello
cyantist Posted - 02/24/2010 : 09:56:41 AM
Fantastic, thanks TreeNode! :)
TreeNode Posted - 02/24/2010 : 07:22:19 AM
Hi cyantist,

I found a very simple way to do it, in case you want to distribute
the columns in new created worksheets.
I think its not the best way to do this, but searching in a rush I didnt find a better
way yet.


void distribute_columns_ex()
{
	WorksheetPage wpMain;
	Worksheet wksMain, wks1, wks2, wks3;
	
	// main Worksheet must be activated
	wpMain = Project.Pages();	// --> activatetd book 
	wksMain = wpMain.Layers();	// --> activated sheet
	
	// create new worksheets and delete needless columns
	wks1.CreateCopy(wksMain);
	wks1.DeleteCol(2);	// after deleting column with index 2 (third column)
	wks1.DeleteCol(2);	// the next columns update there index
	wks1.DeleteCol(2);
	wks1.DeleteCol(2);
	
	wks2.CreateCopy(wksMain);
	wks2.DeleteCol(1);
	wks2.DeleteCol(2);
	wks2.DeleteCol(2);
	wks2.DeleteCol(3);
	
	wks3.CreateCopy(wksMain);
	wks3.DeleteCol(1);
	wks3.DeleteCol(1);
	wks3.DeleteCol(3);
	wks3.DeleteCol(3);
}


I tested this with a Workbook with one Worksheet, which had 7 columns.
First column was X-designated holding row index. The other 6 columns had sample data
random numbers).

So if you just want do distribute the columns of a Worksheet into new created ones,
this shows a very simple way. Probably its not the nicest one, but who cares...? ;D

But if you want to distribute the columns to existing Worksheet, you cant do it
like that.
I searched for a way to just add a Column object to an existing Worksheet. So
that you could do something like this:


{
	...

	Column col;
	col.Attach( wksMain.GetName(), index );

	wks1.AddCol( col ); // this is not supported, but would be nice...

        ...
}


When I find a better way to do things like that, I will let you know.


|-- TreeNode
...|-- a??
...|-- ha!!

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