Ask a questionAsk a question
 

Proposed AnswerReportViewer Export

  • Thursday, October 29, 2009 11:37 AMSyed Shujaat Hussain Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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).
    • Edited bySyed Shujaat Hussain Monday, November 02, 2009 2:38 PMTo tell this is a Windows app.
    • Moved byHarry ZhuMSFTMonday, November 02, 2009 5:21 AMrelating to report viewer control (From:Visual C# General)
    •  

All Replies

  • Monday, November 02, 2009 11:47 AMRajaSekhar-Navigator Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer

    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 02, 2009 2:37 PMSyed Shujaat Hussain Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks, but this is a Windows application, not a website. Do you think your solution will work with that too?