Appending leading Zeros and writting to excel file

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
neo637
Participant
Posts: 9
Joined: Thu Jul 31, 2008 2:56 am

Appending leading Zeros and writting to excel file

Post by neo637 »

Hi,

I am trying to generate excel file in data stage.
In doing so i have a problem, When i am trying to append leading Zeros to a filed and witting into excel file all the leading zeros are stripped off.

Can some one help ma in solving this.

Thanks in advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First, define "excel file" - .xls or .csv? And are they "stripped off" in the file you generated or after loading the file into Excel?
-craig

"You can never have too many knives" -- Logan Nine Fingers
neo637
Participant
Posts: 9
Joined: Thu Jul 31, 2008 2:56 am

Post by neo637 »

Hi Craig,

the excel file is .xls.
The leading zeros are stripped off after witting in to xls file.

Thanks
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

neo637 wrote:Hi Craig,

the excel file is .xls.
The leading zeros are stripped off after witting in to xls file.

Thanks
That's because the column format is Number and not Text, and hence, Excel considers the leading zero useless... and deletes it. You will need to change the column to Text.
gateleys
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or change the format of the cells if they really must be Number.

It's NOT a DataStage issue.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
neo637
Participant
Posts: 9
Joined: Thu Jul 31, 2008 2:56 am

Post by neo637 »

Hi

Thanks for ur sugession.
Yes even i do agree with your comments.
Its not a datastage issue but the cell properties of .xls file are always
taken as general by default.

When the generate the file the defaulf cell prperties are General, So could you please help me is there any way can we change the cell properties ti text or Number dynamically.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Work in csv or txt.

Prefix all with a dummy character so all will be text.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can you prefix the result with a single quote character, so that Excel treats the value as literal text?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
neo637
Participant
Posts: 9
Joined: Thu Jul 31, 2008 2:56 am

Post by neo637 »

Yes i even tried out with the prefix (') quote charector.
Its is working fine, But the i have one more concern here.
If some system process the same excel file what i generated will the value of the filed will have quote?
Like if they trying to load the same file in to a Database then that particular filed wil have only Number value in the Table or with quote and Number.

Could you please help me in this.

Or some one can suggest if there is any way handling the properties of an .xls cell with UNIX shell scripting.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There is no way to manipulate an Excel workbook with UNIX scripting because Excel does not run on UNIX machines.

In my experience the only effect of the leading single quote is to force Excel to accept the following value as text. There are no real data types within Excel - if that value can participate in numeric operations (that is, if that value is numeric in any sense) then it will not throw an error.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply