问题
I'm working with SSRS 2008 in some existing reports I have. One of the new requirements is to add a few columns and two of them begins with a number in its header. For example: 170T_Test.
When displaying the data and headers in the Report Viewer all is OK.
HOWEVER, the problem is when exporting to CSV format. Since the headers showed in this format are taken from the textbox property name, I had to put 170T_Test as the name. But, trying to do that the SSRSS 2008 IDE shows the following messages error:
"Specify a valid name. The name cannot contain spaces, and it must begin with a letter followed by letter, numbers, or the undescore character (_)"
So, based on all the explained above, is there a way to have the textbox starting with a number? or is it prohibited?
Regards!
回答1:
It can be achieved in two different ways.
I prefer method 1. It is much better and reuseable.
Method 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 '170T Test' AS Field1, '180 T$' AS Field2, 1 as rowOrder
) ORDER BY rowOrder
Step 2:
Modify the RSReportServer.config
file on Report server to customize CSV export to exclude header.
2012 config file Location: C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer
2008 File Location: \Program Files\Microsoft SQL Server\MSSQL.n\Reporting Services\ReportServer
Imp: Make a backup of the RSReportServer.config
in case you need to rollback your changes.
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>
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 the way they want.
MSDN Link to customize Rendering extension
Method 2:
STEP 1
Same as above
STEP 2 Use URL access and specify the device info for no header http://msdn.microsoft.com/en-us/library/ms155046.aspx
回答2:
Resources can't start with a number or a reserved word, if you do this, visual studio will automaticly add an underscore '_' in front of your name. Your problem probably has something to do with this.
来源:https://stackoverflow.com/questions/22637444/textbox-name-cannot-start-with-a-number-in-ssrs2008