报表生成器导出到带有列标题空间的 CSV [英] Report Builder Export to CSV with colum header spaces
问题描述
这是一个奇怪的请求,因为我们都知道数据库头不应该包含空格.但是,我正在使用的系统需要在其标题中使用空格才能导入.我创建了一个 Report Builder 报告,它将数据构建到一个表中,并在我运行它时工作.
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 行的标题.
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 FilesMicrosoft SQL ServerMSRS11.MSSQLSERVERReporting ServicesReportServer
2012 config file Location: C:Program FilesMicrosoft SQL ServerMSRS11.MSSQLSERVERReporting ServicesReportServer
2008 文件位置:Program FilesMicrosoft SQL ServerMSSQL.nReporting ServicesReportServer
Imp: 备份 RSReportServer.config
,以防您需要回滚更改.
Imp: Make a backup of the RSReportServer.config
in case you need to rollback your changes.
在 CSV 扩展名下方的
部分添加另一个条目.
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.
这篇关于报表生成器导出到带有列标题空间的 CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!