ReportViewer With Page Breaks vs. Excel Without

Discussion in 'ASP .Net Web Controls' started by Dave, Feb 5, 2008.

  1. Dave

    Dave Guest

    Using VS2008 web applicaiton with the ReportViewer.

    Have a report that has (and needs) page breaks. When this report is
    exported to Excel, we need the report to appear on one sheet instead of one
    sheet per page. Is there a way to accomplish this?

    On a slightly different topic, there are textboxes on the report that span
    several lines. When these appear in Excel, the heigh of the cell is set so
    that only the first line is visible. Is there a way to get excel to
    automatically adjust the cell height to display the full contents?
    Dave, Feb 5, 2008
    1. Advertisements

  2. Hello,

    From your post, my understanding on this issue is: you wonder (1) How to
    export contents separated with page breaks in a rdlc to *one* worksheet,
    and (2) How to make the report viewer adjust the exported worksheet cell's
    height to fit the content of textboxes in the rdlc. If I'm off base, please
    feel free to let me know.

    For you first question "How to export contents separated with page breaks
    in a rdlc to *one* worksheet", I have to let you know that it is a
    by-design behavior of the Report Viewer control to export the report to
    several worksheets when there are page breaks in it. We are not able to
    interfere with the action when the control is exporting the content to a

    However, a possible solution is:
    1. Set the report viewer control's ShowExportControls = False
    2. Add a new rdlc which is copied from your original rdlc, then remove all
    the page breaks in it so that the new rdlc will be rendered to only one
    3. Add a button ("Generate Excel Report") to the web page, in the button's
    Click event handler, add the following:
    ReportViewer rv = new ReportViewer();
    rv.ProcessingMode = ProcessingMode.Local;
    rv.LocalReport.ReportPath = Server.MapPath("Report2.rdlc"); //
    point to the new rdlc without page breaks
    rv.LocalReport.DataSources.Add(...); // your report data source
    Warning[] warnings;
    string[] streamids;
    string mimeType;
    string encoding;
    string extension;
    byte[] bytes = rv.LocalReport.Render("EXCEL", null, out mimeType,
    out encoding, out extension, out streamids, out warnings);

    HttpContext.Current.Response.ContentType =
    "attachment; filename=Report.xls");
    Please have a try and let me know if it works for you.

    For your second question "How to make the report viewer adjust the exported
    worksheet cell's height to fit the content of textboxes in the rdlc.":
    Based on my test, the cells in the worksheet generated by the report viewer
    have been adjusted to the proper height. Here is my test steps:
    1. Drag and drop a Textbox from Report Items Toolbox to the rdlc
    2. Resize the Textbox control to 1.25in, 0.375in, and type a very long text
    into it.
    If I set the Textbox's CanGrow property as False, the generated report and
    excel file shows the textbox as size: 1.25in, 0.375in.
    If I set the Textbox's CanGrow property as True, the generated report and
    excel file will adjust the textbox's height so that all the text in it can
    be shown.

    I am not able to reproduce the issue that "only the first line is displayed
    in the generated worksheet". Am I misunderstanding your question? Or would
    you send a sample to my mailbox so that I can have a clearer picture of the
    problem? My mailbox: , remove 'nospam.'

    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    For MSDN subscribers whose posts are left unanswered, please check this

    Get notification to my posts through email? Please refer to
    ications. If you are using Outlook Express/Windows Mail, please make sure
    you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
    see your reply promptly.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], Feb 6, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.