none
ReportViewer Export RRS feed

  • Question

  • Hi, Is there any way to show the Export dialog of ReportViewer programmatically? Please note that I want to show the Export dialog and not actually export the report. The code should be an exact equivalent of pressing the Export button on the reportviewer toolbar. (This is a Windows application, not a website).
    • Moved by Harry Zhu Monday, November 2, 2009 5:21 AM relating to report viewer control (From:Visual C# General)
    • Edited by Syed Shujaat Hussain Monday, November 2, 2009 2:38 PM To tell this is a Windows app.
    Thursday, October 29, 2009 11:37 AM

All replies

  • HI,
    Below code will provide exporting to PDF, you can change to "excell" insted of PDF to export to excell,
    use this code after you provide the data source and report path, it will pop up directly "open" "save" "cancle" dialog of the report.

    Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing

    Dim streamids As String() = Nothing

    Dim mimeType As String = Nothing

    Dim encoding As String = Nothing

    Dim extension As String = Nothing

    Dim bytes As Byte()

    Dim DeviceInfo As String = "<DeviceInfo>" _

    & " <OutputFormat>PDF</OutputFormat>" _

    & " <PageWidth>7.7in</PageWidth>" _

    & " <PageHeight>11in</PageHeight>" _

    & " <MarginTop>0.39in</MarginTop>" _

    & " <MarginLeft>0.64in</MarginLeft>" _

    & " <MarginRight>0.25in</MarginRight>" _

    & " <MarginBottom>0.39in</MarginBottom>" _

    & "</DeviceInfo>"

    'Rendering pdf settings to ReportViewer

    bytes = reportViewer1.LocalReport.Render("PDF", DeviceInfo, mimeType,

     

    encoding, extension, streamids, warnings)

    Response.Clear()

    Response.ContentType = mimeType

    Response.AddHeader("content-disposition", "attachment;filename=Sample"extension)

    Response.BinaryWrite(bytes)

    Response.End()

    Hope this will help you

    -Raja Sekhar K

    Monday, November 2, 2009 11:47 AM
  • Thanks, but this is a Windows application, not a website. Do you think your solution will work with that too?
    Monday, November 2, 2009 2:37 PM
  • Wow...Thank you for this!  The toolbar really messes up the report sizes.  This is exactly what i needed. 
    Thursday, March 4, 2010 12:33 AM
  • The export dialog can be invoked programmatically in VS 2010:

    http://msdn.microsoft.com/en-us/library/dd461349(VS.100).aspx
    Thursday, March 4, 2010 1:27 PM
    Moderator