Errors when saving report book reports to Excel

3 posts, 0 answers
  1. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 22 Feb 2012 Link to this post

    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. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 27 Feb 2012 Link to this post

    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.

  3. Manar
    Manar avatar
    12 posts
    Member since:
    Mar 2012

    Posted 31 Jan 2013 Link to this post

    Perfect!! thank you

Back to Top