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
    1. Advertising

  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
    xls.

    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
    page.
    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.Clear();
    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.Clear();
    HttpContext.Current.Response.ContentType =
    "application/vnd.ms-excel";
    HttpContext.Current.Response.AddHeader("Content-disposition",
    "attachment; filename=Report.xls");
    HttpContext.Current.Response.BinaryWrite(bytes);
    HttpContext.Current.Response.End();
    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.'

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

    ==================================================
    For MSDN subscribers whose posts are left unanswered, please check this
    document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    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
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], Feb 6, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sk1I?=

    ReportViewer - Print without Preview

    =?Utf-8?B?Sk1I?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    5,254
    =?Utf-8?B?Sk1I?=
    Apr 24, 2006
  2. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,468
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  3. Bogdan
    Replies:
    0
    Views:
    1,678
    Bogdan
    Sep 18, 2009
  4. John G

    ReportViewer Local Mode Excel Hyperlinks

    John G, May 18, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    928
    John G
    May 18, 2010
  5. fniles
    Replies:
    6
    Views:
    627
    Karl E. Peterson
    Apr 27, 2009
Loading...

Share This Page