Report Builder 使用列 header 空格导出为 CSV
Report Builder Export to CSV with colum header spaces
这是一个奇怪的请求,因为我们都知道数据库 headers 永远不应该包含空格。
但是,我正在使用的系统需要在其 headers 中使用空格才能导入。
我创建了一个 Report Builder 报告,它将数据构建到 table 中,并在我 运行 时工作。
'01/08/2015' "Active date",
'31/07/2016' "Expiry date",
然而,当它被导出到 CSV 文件时,它们被替换为 "Active_date",这会导致导入错误。有谁知道我可以阻止它用 _ 替换空格的方法,或者这是无法更改的东西?
不,这不可能,请参阅下面的链接了解更多详情 -
- SSRS csv export with comma in the column header names
- Is it possible to export to CSV and have the header contain spaces?
是可以使用列 header 中的空格导出到 CSV。这是我实现它的方式。
步骤 1
更新您的报告数据集以在第 1 行包含 headers。
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 导出以 排除 header.
2012 配置文件位置:C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer
2008 文件位置:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer
Imp: 备份 RSReportServer.config
以防您需要回滚更改。
在 CSV 扩展名下方的 <render>
部分添加另一个条目。
<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 格式的数据,其中包含 header.
中的空格
这是一个奇怪的请求,因为我们都知道数据库 headers 永远不应该包含空格。 但是,我正在使用的系统需要在其 headers 中使用空格才能导入。 我创建了一个 Report Builder 报告,它将数据构建到 table 中,并在我 运行 时工作。
'01/08/2015' "Active date",
'31/07/2016' "Expiry date",
然而,当它被导出到 CSV 文件时,它们被替换为 "Active_date",这会导致导入错误。有谁知道我可以阻止它用 _ 替换空格的方法,或者这是无法更改的东西?
不,这不可能,请参阅下面的链接了解更多详情 -
- SSRS csv export with comma in the column header names
- Is it possible to export to CSV and have the header contain spaces?
是可以使用列 header 中的空格导出到 CSV。这是我实现它的方式。
步骤 1
更新您的报告数据集以在第 1 行包含 headers。
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 导出以 排除 header.
2012 配置文件位置:C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer
2008 文件位置:\Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer
Imp: 备份 RSReportServer.config
以防您需要回滚更改。
在 CSV 扩展名下方的 <render>
部分添加另一个条目。
<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 格式的数据,其中包含 header.
中的空格