Last post May 22, 2012 04:40 AM by Noorstudio
May 21, 2012 04:15 AM|Noorstudio|LINK
I have created many Crystal Reports. All reports can either be exported to as Excel/PDF or displayed on screen. Some of these reports must have customized HEADERS. So, I have added Parameters Fields to pass some values from the web form to Crystal Report
viewer. Until now, everything is working as expected as long as displaying on screen. Unfortunately, after adding Parameter Fields to customize the header of the reports, any report is selected to be exported to either Excel or PDF will fail!!!
When exporting to excel, I get an error which says:
The file you are trying to open, 'ExcelFileName.Xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before the opening the file. Do you want to open the file now?
And there are Yes, No and help buttons to select. If chose to select open, the file is then opened with garbage information.
If I take out the parameters added, then, exporting and everything goes OK!!
How to override the problem?
May 22, 2012 04:40 AM|Noorstudio|LINK
Solved! I created a blank formula field in Crystal Report called
'@HeaderLineOne' and used FormulaFields in my webform.
oRpt.DataDefinition.FormulaFields.Item("HeaderLineOne").Text = "'" + "your passed value" + "'"
CrystalReportViewer1.ReportSource = oRpt