Export Reportviewer report to CSV

Asked

Viewed 440 times

10

In the Reportviewer using Winforms, when creating the report I only have the option to export to PDF, Excel and Word and need to add the option to export in CSV.

  • I didn’t get any tips for RDL or RDLC. Already with Crystal Reports (RPT), CSV is already a natural option for export.

  • I looked on the net and I had this answer...

  • If you have control of Dataset you can use this http://stackoverflow.com/a/8810229/6809703, which would be Dataset->CSV, or you could export it to Excel and then turn it into CSV, which you can do all programmatically.

  • You can offer more details, so you can build an example?

  • Using Report Server you can export to Excel, MHTML, PDF, TIFF, XML, and CSV. The local Report does not allow, the way is to look for alternatives as put by the other comments. This link shows you how to hack to export Msword location, which is not a native option for Reportviewer in windows, the process is laborious but you may be able to play CSV: https://www.codeproject.com/Articles/23966/Report-Viewer-generate-reports-MS-Word-formats

  • can help you https://stackoverflow.com/questions/32325592/export-to-csv-in-localreport-of-reportviewer-of-winform

Show 1 more comment

2 answers

-1

public override IEnumerable<ExcelExportInfo> ListExcelExportInfo()
{
    if (this.ExportToExcel == null) 
    { 
        List<ExcelExportInfo> list = new List<ExcelExportInfo>(); 

        Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer renderer = new Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer(); 
        list.Add(new ExcelExportInfo("Excel", renderer.LocalizedName, true, typeof(Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer), true));

        this.ExportToExcel = list; 
    } 
    return this.ExportToExcel; 
}

-1

private void reportViewer_Load(object sender, EventArgs e) { var fieldInfo = typeof(Microsoft.Reporting.WinForms.RenderingExtension).GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

foreach (var extension in this.reportViewer.LocalReport.ListRenderingExtensions())
{
    if (string.Compare("EXCELOPENXML", extension.Name) == 0)
        fieldInfo.SetValue(extension, true);
}}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.