+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: CSV File Export Tip...

  1. #1
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    CSV File Export Tip...

    If you ever export your data to CSV using Reporting Services, you might notice that the file does not open correctly in Excel (which should usually recognize CSV format). You might also note that programs expecting a standard CSV file will not be able to use CSV files exported from Reporting Services. The reason for this is that the encoding is set to Unicode by default instead of ASCII.

    Here is a tip to solve that problem. For SQL Reporting Services 2005, change the config file on the report server as follows:

    1. Open the rsreportserver.config file with a text editor and look for this block:
    <Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.CsvRen derer.CsvReport,Microsoft. ReportingServices.CsvRendering"/>

    2. Comment out that section with <!-- and --> marks.

    3. Directly below that comment section, add the following:

    <Extension Name="CSV"
    Type="Microsoft.ReportingServices.Rendering.CsvRen derer.CsvReport,
    Microsoft.ReportingServices.CsvRendering">
    <Configuration>
    <DeviceInfo>
    <Encoding>ASCII</Encoding>
    </DeviceInfo>
    </Configuration>
    </Extension>

    4. Run IISRESTART to reload the configuration file.

    If you do not have SQL Reporting Services 2005, you can edit the URL. If you'll notice, the URL strings have parameters in them telling the report how to render. You can force the report to render as CSV and change the encoding to ASCII by placing these in the URL string.

    1. Replace this block in the URL:
    Code:
    rs%3aCommand=Render&rs%3aFormat=HTML4.0
    
    with
    Code:
    rs%3aCommand=Render&rs%3aFormat=csv
    
    2. Then add the following bit:
    Code:
    rc:Encoding=ASCII
    
    3. Make sure to append using the ampersand &

    4. It should prompt you to download the report. Just open or save it, and your encoding will be correct.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  2. #2
    Barn Newbie toddlemen is an unknown quantity at this point toddlemen's Avatar
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    3

    Text file name change result?

    Thank you for the post - most helpful. I've noticed this process changes the name of the resulting file from ".csv" to ".csv.txt". Is is possible to instruct RS to name the file ".csv" and not add the additional ".txt" with I add the ASCII encode command snippet?

  3. #3
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Hi There!

    Which process are you using? Were you able to change the Report Server configuration, or did you have to resort to changing the URL? Does this happen every time you export the file as CSV?

    P.S. I just re-tested adding the rc:Encoding=ASCII in the url just in case that was your method, and it does work but... you have to remember to add an ampersand before the rc:Encoding=ASCII (and after it if it is not at the end of your URL).
    Last edited by Lauramc; March 16th, 2009 at 02:51 PM.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  4. #4
    Barn Newbie toddlemen is an unknown quantity at this point toddlemen's Avatar
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    3

    URL and CSV

    Because the Report Server manages a host of existing output work, reconfiguing the defaults would be unacceptably disruptive. So, I do string the URL to include the '&rc:Encoding=ASCII' snippet. A fixed file name would be quite alright (e.g., myreport.csv). While requiring users to rename a file titled myreport.csv.txt to myreport.csv, I'd love to be able to "tell" Reporting Services to simply name the file myreport.csv and save the users a step.
    SQL RS 2K, BTW...

    Thanks again!

  5. #5
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Hello Again,

    I also have used the URL option, and so far find that it works without changing the extension to csv.txt. So... I am wondering if you are doing this somehow differently. Did you also change the rendering format tag? In other words change:
    Code:
    rs%3aCommand=Render&rs%3aFormat=HTML4.0
    
    to
    Code:
    rs%3aCommand=Render&rs%3aFormat=csv
    
    That should ensure that you have the correct format.

    The only thing I can think of is that the machine in question might associate CSV with a TXT file instead of Excel CSV. You might check the file associations, or if you do not have Excel (or your users do not), that might be the cause.

    As for the larger question of whether you can force the extension, I do not believe that you can do so. I know if you set up a suscription you can force the name of the file, but again... I am not sure that the extension would change.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  6. #6
    Barn Newbie toddlemen is an unknown quantity at this point toddlemen's Avatar
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    3

    K. Thanks again!

  7. #7
    Barn Newbie harish is on a distinguished road harish's Avatar
    Join Date
    Apr 2009
    Posts
    37
    Rep Power
    3

    Not working

    Hi,

    Somehow the given settings does not worked in environment. I had followed the same steps as listed.

    I am working with SSRS 2005, on Windows 2003 server machine.

    Are there any other ideas, ways to achieve the same?

    Regards,
    ~Harish

  8. #8
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    You can try the URL change. I posted steps for that as well just in case anyone had trouble with changing the configuration file.

    What version of Reporting Services are you using? That will make all the difference, because if you are using the version that comes with VS 2003, the configuration change will not work.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  9. #9
    Barn Newbie harish is on a distinguished road harish's Avatar
    Join Date
    Apr 2009
    Posts
    37
    Rep Power
    3

    As mentioned in the post, I am working with SSRS 2005. I did try to change the URL but unfortunately it is not allowing me to do the changes in the URL. As soon as I click on Export, it ask immediately to open, save or cancel the request.

    Pls. do confirm, I am trying to do the changes at the right place or do I have to make the changes in the config file only.

    Regards,
    ~Harish

  10. #10
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    Hi Harish,

    The dialog will still show up if you change the URL... that is true. You will be prompted to open or save. Once you have saved the file try opening it, and you should see that the formatting is correct.

    If you want to make this change for reports on a subscription, you will have to make the change in the configuration file. Make sure that you are changing the file on the server (and if you have more than one installed, you'll have to change it on all of them).

    Double check your config changes. Make sure that you have commented out this section:
    Code:
    <Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.CsvRen derer.CsvReport,Microsoft. ReportingServices.CsvRendering"/>
    
    Futhermore make sure that you have added this code:
    Code:
    <Extension Name="CSV"
    Type="Microsoft.ReportingServices.Rendering.CsvRenderer.CsvReport,
    Microsoft.ReportingServices.CsvRendering">
    <Configuration>
    <DeviceInfo>
    <Encoding>ASCII</Encoding>
    </DeviceInfo>
    </Configuration>
    </Extension>
    
    Finally, make sure that IIS was restarted for the changes to take effect.

    Good luck, and let me know if this works for you.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

+ Reply to Thread
Page 1 of 2 1 2 LastLast

LinkBacks (?)

  1. May 21st, 2009, 01:32 PM
  2. May 20th, 2009, 03:56 AM
  3. May 11th, 2009, 06:23 PM
  4. May 11th, 2009, 06:14 AM
  5. April 23rd, 2009, 02:04 PM
  6. April 21st, 2009, 07:57 AM
  7. April 21st, 2009, 06:50 AM
  8. April 9th, 2009, 01:08 PM
  9. April 8th, 2009, 05:05 AM
  10. March 30th, 2009, 09:33 AM
  11. February 25th, 2009, 10:33 AM
  12. January 30th, 2009, 01:45 PM
  13. January 6th, 2009, 01:37 PM
  14. December 8th, 2008, 02:33 PM
  15. November 25th, 2008, 04:41 PM
  16. November 17th, 2008, 04:10 PM
  17. October 29th, 2008, 11:12 PM
  18. October 14th, 2008, 11:11 PM
  19. October 14th, 2008, 10:52 AM
  20. October 14th, 2008, 08:22 AM
  21. October 14th, 2008, 07:35 AM

Similar Threads

  1. export to excel function prompt help
    By Rebelle in forum JavaScript Programming
    Replies: 2
    Last Post: April 14th, 2008, 11:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO