Author |
Topic  |
|
jgeskey
USA
Posts |
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.
|
|
Mike Buess
USA
3037 Posts |
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 |
 |
|
jgeskey
USA
Posts |
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 |
 |
|
|
Topic  |
|
|
|