This is a migrated thread and some comments may be shown as answers.

Errors when saving report book reports to Excel

2 Answers 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dave Hayward
Top achievements
Rank 1
Dave Hayward asked on 23 Feb 2012, 03:52 AM
I am combining multiple identical reports in a report book and then saving the rendered report in an Excel 97-2003 Worksheet file. I'm getting the following error when Excel tries to open the generated report:

"Excel found unreadable content in 'PulledOrders.xls' Do you want to recover the content of this workbook? If you trust the source of this workbook, click Yes."

Trusting in myself, I click yes and Excel repairs the file claiming it renamed an invalid worksheet name for each report (I'm naming each report with a unique name using report.Name). The excel file then has one perfectly rendered worksheet with the name I gave it and an identical one beside it with a name like 'Recovered_Sheet1'.

What am I doing that would cause this. Is there a special way to set each name in a report book that's different from naming each report?

BTW, I'm not using the viewer for any of this, just rendering the file directly.

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 27 Feb 2012, 03:23 PM
Hello Dave,

Each report in a ReportBook will occupy a separate worksheet in the Excel workbook and each worksheet of the Excel workbook will have the name of the respective report. The name of the document if not explicitly set via the DocumentName Property would be the name of the report class. In your scenario, you use multiple instances of the same report class, so the Excel rendering tries to add the same name to all worksheets, which is not allowed by MS Excel. To resolve this simply set a desired name to the reports e.g.:

Copy Code
protected void Button1_Click(object sender, EventArgs e)
        {
            Telerik.Reporting.ReportBook reportbook = (Telerik.Reporting.ReportBook)this.ReportViewer1.Report;
            reportbook.Reports[1].DocumentName = "report2";
            reportbook.Reports[2].DocumentName = "report3";
            ......
        }



Greetings,
Steve
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
0
Manar
Top achievements
Rank 1
answered on 31 Jan 2013, 02:55 PM
Perfect!! thank you
Tags
General Discussions
Asked by
Dave Hayward
Top achievements
Rank 1
Answers by
Steve
Telerik team
Manar
Top achievements
Rank 1
Share this question
or