How to export a csv without header in SSRS

╄→尐↘猪︶ㄣ 提交于 2020-01-02 07:08:12

问题


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.


回答1:


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




回答2:


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" 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.




回答3:


Adding this:

<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>

To the config file here: C:\Program Files\Microsoft SQL Server{INSTANCE}\Reporting Services\ReportServer\rsreportserver.config (In the section)

Will create another option in the dropdown list of export options but will still use the CSV Format (Microsoft.ReportingServices.DataRenderer) so the users can still choose per report which format they want.




回答4:


For those looking for an export option using only URL access, as suggested by @Stacia, you can request a CSV export with the no header option, just include this in your request: rc:NoHeader (namespace is rc: not rs:)

Sample URL: http://localhost/ReportServer/?ReportName&rs:Command=Render&rs:Format=CSV&rc:NoHeader=true



来源:https://stackoverflow.com/questions/11531896/how-to-export-a-csv-without-header-in-ssrs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!