我有一些表需要在 Visual Studio 中创建为 sql server 报告服务报告。报告将导出为 CSV。列标题需要与基础表具有完全相同的名称,因为它将从 CSV 导出到分析软件中。问题是报告向导格式化我的列标题,即CustomerName将变为Customer Name,并带有空格。有没有办法在标题中使用相同的列名?数据集列标题是正确的,但在报告本身中它被格式化。
有些表有超过 100 列,这就是我使用向导的原因。谢谢!
我有一些表需要在 Visual Studio 中创建为 sql server 报告服务报告。报告将导出为 CSV。列标题需要与基础表具有完全相同的名称,因为它将从 CSV 导出到分析软件中。问题是报告向导格式化我的列标题,即CustomerName将变为Customer Name,并带有空格。有没有办法在标题中使用相同的列名?数据集列标题是正确的,但在报告本身中它被格式化。
有些表有超过 100 列,这就是我使用向导的原因。谢谢!
There's good news and bad news.
I've never really used the Report Wizard, but it does seem to be the best option in your case.
The bad news is, in my quick test with the wizard, there seems to be no option for formatting headers like you're suggesting in the report.
The good news is that these don't actually affect the CSV export.
When exporting a table to CSV, SSRS uses the textbox DataElementName property to determine the CSV header column, and of that's not present it uses the textbox Name property.
Testing with the simplest possible dataset:
create table csvtest (CustomerName varchar(100))
insert into csvtest select 'customer1'
insert into csvtest select 'customer2'
And adding this to a report through the wizard I get the same result as you, i.e. the table header row is Customer Name:
However, the actual CustomerName textbox just inherits the name of the source column:
The end results is that when you export the table to CSV, it doesn't consider the Customer Name value in the table header row and just creates the CSV column header as CustomerName, as required:
So if you can live with the report looking different than you might expect, the CSV export might be correct in spite of the quirks of SSRS.
I would recommend trying the CSV export based on the wizard and seeing how it looks.