• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 865
  • Last Modified:

ASP Classic export data to csv

In classic ASP below code exports the data to csv perfectly but on all  but on field1 it truncats the  leading zero from  "0023423" to 23423.  On export how can I keep value as   "0023423"

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment; filename=filename.csv"

Response.Write( "ComumnName1,")
Response.Write( "ComumnName2")

Do Until RS.EOF
    Response.write """" & .Fields("Field1").value  & """" & ","
    Response.write """" & .Fields("Field2").value  & """" & ","
    Response.write "," & vbcrlf
RS.MoveNext
Loop
0
Bharat Guru
Asked:
Bharat Guru
1 Solution
 
Paul MacDonaldDirector, Information SystemsCommented:
Cast the value as a string instead of an integer.  Try...

...
Response.write """" & CSTR(.Fields("Field1").value)  & """" & ","
...
0
 
BlueKaranaCommented:
It's a cell format issue. All "general format" cells in Excel get the leading zeros truncated off.

You need to format the data in ASP like this: ="000092374234"

This article explains it really well: http://support.microsoft.com/kb/260239

 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now