Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export a csv without header in SSRS

Is there any way of turning off the header for a CSV export on just one SSRS report?

I'm using Report Builder 3 and I deleted the headers from the report, but when exporting to CSV they're back. I can't find anywhere to turn them off.

I've seen this question but it seems to cover all reports on the server, I only need to turn the headers off for a couple.

like image 729
stuartdotnet Avatar asked Jul 17 '12 22:07

stuartdotnet


2 Answers

However you implement this (custom assembly, custom rendering extension), you will need to touch some of the config files on the server, unless you are sending the deviceinfo parameter with the URL, or rendering the report programmatically from an external app.

The easier approach is server wide, and you leave the current CSv extension alone and is very easy to implement. Luckily for you (and me), this is something that can be done with hardly any code at all.

Since this is one of the deviceinfo parameters for the CSV extension, all you have to do is add the following lines of code into the RSReportServer.config file. You are adding another extension here by using the current CSV one.

<Extension Name="CSV (No Header)" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering">
    <OverrideNames>
       <Name Language="en-us"> CSV No Header</Name>
    </OverrideNames>
    <Configuration>
       <DeviceInfo>
          <NoHeader>true</NoHeader>
       </DeviceInfo>
    </Configuration>
</Extension>

Place this in the line below the CSV extension line of code that's already there, or anywhere inside the Render element.

This will allow you to subscribe to the report using that new extension or to export the report using the drop down menu, as sql server reporting services queries that xml file when populating the drop down menu.

If you do use a button and instantiate Reportexecutionservice, you will have to touch the config files anyway to use the .dll.

like image 79
uh_big_mike_boi Avatar answered Sep 30 '22 11:09

uh_big_mike_boi


You can't do anything with the data driven subscription out of the box. It might be possible to write a custom subscription extension to do it. You also cannot do anything about exporting directly from Report Builder, unless you did something clever like add a freestanding textbox that looks like a button and then associate an action with it that creates a URL for you to open/render a report using URL Access. You can see some information here: http://msdn.microsoft.com/en-us/library/ms155046.aspx.

With URL Access you can pass in the CSV device info, in your case NoHeader=true as per http://msdn.microsoft.com/en-us/library/ms155365.aspx

like image 33
Stacia Avatar answered Sep 30 '22 10:09

Stacia