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
 setting column formats

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
jgeskey Posted - 05/23/2006 : 12:57:10 PM
Origin Version (Select Help-->About Origin): 7.5 SR4
Operating System: WinXP pro

hi,

I'm writing a function to import some ascii text. Once the text is imported I want to format the columns to match the data. Everything works perfectly except formatting the date column. We have our own standard date format I'm stuck with using, its:

yyyyMMdd HHmmss.sssZ

I've added it to the custom2 format under date properties and it works great selecting it manually. The problem is I want my function to do it for me, the user won't be able to select it manually.

what I have is:

wks.Columns(0).SetFormat(OKCOLTYPE_DATE);
wks.Columns(0).SetSubFormat(20);

when the column is automatically set to date, all data is replaced with a dash because origin does not recognize it as a date, before it gets a chance to change the subformat to my custom format. Doing it manually I can select them both at once so the data is not lost. Is there a way I can nest these 2 together?

any help would be much appreciated.










2   L A T E S T    R E P L I E S    (Newest First)
jgeskey Posted - 05/24/2006 : 10:09:50 AM
Mike,

you the man, wish I had though of that myself. I used your make a new column, format it, copy the data to it, and delete the old column. It works like a charm.

thanks again :-)

john
Mike Buess Posted - 05/23/2006 : 3:59:42 PM
It's tricky to format a Date column by code after it's filled with text because everything turns to missing values. Safer to format the column before you import its values. If that's not possible (I don't know how your are importing) you can create and format a new column and then copy over the date strings like this...

string str1,str2 = wks.Columns(0).GetName();
wks.InsertCol(0,"Date",str1);
wks.Columns(0).SetFormat(OKCOLTYPE_DATE);
wks.Columns(0).SetSubFormat(20);
Dataset ds0(wks,0),ds1(wks,1);
StringArray sa;
ds1.GetStringArray(sa);
ds0.PutStringArray(sa);
wks.DeleteCol(1); // delete original date column
wks.Columns(0).SetName(str2); // rename new date column

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 05/23/2006 5:46:50 PM

Edited by - Mike Buess on 05/24/2006 08:31:43 AM

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