tags:

views:

28

answers:

1

Hello All,

I am exporting data to .csv file from asp page. I am facing problem in the column which is showing date. Some date comes left aligned and some comes right aligned. As such there is no difference in the dates coming because I am just looping a recordset and writing the rs field which has datetime data.

Note: When I append " " to the datefield then it comes properly but then user cannot format that column to datetime as it no more remains date but a string.

rsDateSet = """ """ rs("AuthorDate") & """," ## This works fine and aligns the column but it converts the column into string so user is not able to format that column to any desired date format he/she wants.

Any helps appreciated.

Thanks

Varun R Doharey

[email protected] [email protected]

+1  A: 

I assume that your problem is when the CSV is opened in Excel.

Unfortunately, if you use CSV, your data will be interpreted in different ways depending on the locale of the program and the different setting that the user could change.

It is more advisable to use other format, as SpreadSheetML (open format XML) (see my answer about this)

Anyway, on the topic, if you want to be safe, you can use functions in your generated CSV to show dates and numbers like:

  =DATE(2009;10;1)

Or using

  =1234/100

to get the decimal number 12.34

Eduardo Molteni
Hi Eduardo,Sorry for late reply.Yes you may be correct that probs come when we open csv in the excel. But as you know clients are used to excel and if we suggest them something like SpreadSheetXML they won't agree. And as such nothing can be done in the asp code. And using functions like you suggested is more to techy and as you know clients are not much techy savvy. Anyways Thanks a lot.
Varun R Doharey
I guess you get me wrong. You can change to SpreadSheetXML and the client will not notice anything different: they download a file witch they can open with excel (double click) and it is perfectly formatted. Same case with the functions, they will not see the functions, only the dates and numbers.
Eduardo Molteni