excelssrs-2012report-viewer2012

SSRS export to xlsx broken?


I have reports which I'd like to render to excel using just a link. In order to do this, I have a page (web application, actually) which uses the ReportViewer to select the parameters and then intercepts the rendering phase using the following piece of code:

    protected void ReportViewer_SubmittingParameterValues(object sender, Microsoft.Reporting.WebForms.ReportParametersEventArgs e)
    {
        //
        if (e.AutoSubmit == false)
        {
            // Only when default no parameters are set
            ReportViewer.ServerReport.SetParameters(e.Parameters);
            Session["Output"] = ReportViewer.ServerReport.Render("EXCELOPENXML");
            DateTime rendertime = DateTime.Now.ToUniversalTime(); // get the current time so we can add the timestamp to the file name
            Session["Rendertime"] = rendertime.ToString("yyyy-MM-ddTHHmmss");
            e.Cancel = true;    // holds the rendering to the reportviewer webform element
        }
    }

and send this to the user later on.

However, while the rendering to the old Excel format (using ReportViewer.ServerReport.Render("Excel") ) worked great, the rendering to the newer EXCELOPENXML file format delivers a file which Excel 2013 says is damaged.

After I let Excel repair the file, I can't really see any difference in contents of the files, except for some difference in layout. However, I can't deliver a broken application, so I have to make it work. Users won't accept this output. We do need the newer file format because of the large number of rows our reports produce.

Does anyone know if this is a bug in the reportviewer, or is it somthing I'm doing wrong here? Does anyone know a fix?


Solution

  • The answer, in case you're also struggling with this, is that the maximum size of the session is limited and that the export didn't fit within the session variable.