报表生成器导出到带有柱头空间的CSV文件 [英] Report Builder Export to CSV with colum header spaces

查看:152
本文介绍了报表生成器导出到带有柱头空间的CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个奇怪的请求,因为我们都知道数据库头不应包含空格. 但是,我正在使用的系统需要在其标头中导入空格. 我已经创建了一个报告生成器报告,该报告将数据构建到表中并在运行时起作用.

This is a strange request as we all know that database headers should never contain spaces. However a system that I am using requires spaces in its headers to import. I have created a Report Builder report that builds the data into a table and works when I run it.

 '01/08/2015' "Active date",
 '31/07/2016' "Expiry date",

但是,当将其导出到CSV文件时,将其替换为"Active_date",这会导致导入错误.有谁知道我可以阻止它用_代替空格的方法,或者这是无法更改的东西吗?

However when this is exported to a CSV file the are replaced with "Active_date" which causes an error on import. Does anyone know a way I can stop it from replacing spaces with _ or is this something that cannot be altered?

推荐答案

是.可以使用列标题中的空格导出到CSV.这就是我实现它的方式.

Yes It is possible to export to CSV with the spaces in column header. Here's how I achieved it.

第1步
更新您的报告数据集,使其在第1行包含标题.

Step 1
Update your report dataset to include the headers on row 1.

SELECT * FROM
(
 SELECT Field1, Field2, 2 as rowOrder
  FROM Tables
  Where Conditions
 UNION ALL
 SELECT 'Activity Date' AS Field1, 'Expiry Date' AS Field2, 1 as rowOrder
) ORDER BY rowOrder

第2步:
修改报表服务器上的RSReportServer.config文件,以将CSV导出自定义为排除标头.

Step 2:
Modify the RSReportServer.config file on Report server to customize CSV export to exclude header.

2012配置文件位置:C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer

2012 config file Location: C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer

2008文件位置:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer

2008 File Location: \Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer

提示:如果需要回滚更改,请备份RSReportServer.config.

Imp: Make a backup of the RSReportServer.config in case you need to rollback your changes.

在CSV扩展名下面的<render>部分中添加另一个条目.

Add another entry in <render> section below CSV extension.

<Extension name="CSVNoHeader" 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>

保存.现在,您还有另一个下拉导出选项 CSV No Header ,以及CSV,PDF,XML.用户可以使用此选项以CSV格式提取数据,并在标题中添加空格.

Save it. Now you have another drop down export option CSV No Header along with CSV, PDF, XML. Users can use this option to extract the data in CSV with the spaces in the header.

用于自定义渲染扩展的MSDN链接

这篇关于报表生成器导出到带有柱头空间的CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆