question

SANJEEV_MATTE avatar image
SANJEEV_MATTE asked

Export to csv

Hello All, I am using SSRS 2008 R2. I have developed a report and one of the columns returning values as 0113,0234. when i am exporting to CSV format it is showing as 113,234. I want to 0 also to be the part of that number. Please give me the solution.
ssrs-2008-r2csv
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
This site runs off of votes. Please mark all helpful answers by clicking on the thumbs up next to those answers. If any one answer lead to a solution, please indicate that by clicking on the check mark next to that answer.
0 Likes 0 ·
sp_lock avatar image
sp_lock answered
One option is to convert the field to a string within the report, so when it exports to excel it doesn't treat it as a number. [ http://msdn.microsoft.com/en-us/library/ms157328.aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ms157328.aspx
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

SANJEEV_MATTE avatar image SANJEEV_MATTE commented ·
Thanks for your reply. I am already converting my values into string (=Cstr(field)). I don't want to export it in Excel. I want it in CSV.
0 Likes 0 ·
sp_lock avatar image sp_lock SANJEEV_MATTE commented ·
What is the data type of the source column? I have just run a test returning 09.00 as a string and the extract to CSV includes the leading zero. Thanks
0 Likes 0 ·
SANJEEV_MATTE avatar image SANJEEV_MATTE commented ·
It is varchar
0 Likes 0 ·
vivekyadav0212 avatar image
vivekyadav0212 answered
As you say that you are already getting the leading zeros in a number, this means you have already converted that in string.[CAST('00000'as varchar)] Then there should be no issue in exporting to CSV. I did the same thing and got all leading zeros. Name,Number A,10001 B,10001 C,010001 D,10001 E,00000 You must be opening the CSV in Excel, try to open that in notepad. You will get all the leading zeros. Excel treat them as numbers, so will definitely remove zeros.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.