Issues in the Format in excel file generated from unix machine

Hi,

I have generated a report that contains many columns and since I need ir in excel format.. I just renamed te file to excel as follows:

cp vijay.txt vijay.xls

I have just attached this spreadsheet in the mail and I am getting it to my mail id. But, in the output excel, the columns that have text xharacters are displayed correctly. Example:

Office name Office number employee name emp number
----------- -------------- --------------- --------------
trichy 012345 vijay 82389
chennai 008393 arun 00123
madurai 037489 vaas 82738
salem 134567 allen 92389

here...
the excel shows the second column as

12345
8393
37489
134567

excluding the zeros .. also in the last column

00123 as 123.

I need these zeros to be included in the excel output..

Is there any way this can be obtained?
Please help me to resolve this issue.

Thanks,
Vijayakumar.

You could either tell excel that the column is text or just put " symbols round the number.

I give up. :frowning:

You should be doing "cp vijay.txt vijay.csv"

XLS is for Microsoft Excel proprietary binary format files.

You got to specify the Column data format of the field as "Text" and not as "General"

that would consider the numerals as strings and the leading zeroes would remain as such

Thanks for the reply.
Yeah.. U r right....!!
But, every time the report gets generated i need to open it and change the format....rite?

that does not solve the issue... I am going o schedule it in cron..

is there any way to format that excel colums as "text" or "general" in the unix machines itself.

If there are any such, it would help me....

Thanks,
Vijay.

You can force excel to treat numbers as text by using...

chennai,="008393",arun,="00123"

I think Dragon is on to the right answer.

if Excel finds stuff in quotes it should keep it as text.

It doesn't work..
I tried keeping all the values in quotes.

i.e.

chennai as "chennai"
008393 as "008393"

and so on.

But, still the excel file that gets generated to the desktop doesn't has those zeros.

Try with this page
Formatting Cells in Excel

Select all your cells ,then go to the Format menu and then click on the Number tab in the Format Cells dialog box. There is also a choice named Special and when you choose that, you can select formats like Social Security Number, Phone Number, etc.

My OS is Japanese here so I cant try out the excel option..My Office is little different from English Office.

Hope it help you out..

-- user_prady

Well, Ygor's solution works for me:

When I double click on this file in Windows, all leading zeros are preserved.

Maybe you can post the top fiew lines of your output file.

Using double-quotes on their own doesn't work, you need the preceeding equals sign as well.