This project is read-only.

Problem rendering EXCEL file

Jul 14, 2010 at 12:44 AM

I cannot render an excel file for download correctly using SSRS SDK for PHP. I can for a CSV, and I can render one for PDF inline. The contents of produced file is garbage when viewed in EXCEL. Here is my code:

$renderAs = new RenderAsEXCEL();

$result = $ssrs_report->Render2($renderAs, PageCountModeEnum::$Estimate, $Extension, $MimeType, $Encoding, $Warnings, $StreamIds);

header("Content-Type: application/");

header("Content-Disposition: attachment; filename=\"".$reportName.".xls\";");

btw, I've tried many different MIME Content-Type values.

Can other people create an valid Excel file using the SDK?

Jul 14, 2010 at 4:07 AM

Did you try using the GetReports.php app (SSRSReport\Samples\HelloWorld\Code)?

You should be able to select the list of reports, specify the params and pick the format you want to use for rendering the report.

You will have to change the connection params in the file to match your environment. If GetReports work you can check the code in the download.php file for the correct code to use to make sure the Excel file is downloaded correctly.


hope this helps



Jul 15, 2010 at 4:23 PM

needed to call ob_clean()

Nov 3, 2010 at 11:18 AM

the problem is actually that there is a space in front of the first <?php in RenderAsEXCEL.php and there are a few lines after the last ?> in  RenderAsPDF.php

remove these white spaces and you will not have to use this ugly ob_clean() workaround

Feb 4, 2011 at 8:06 PM

@Thunderstriker - you are the man! Thank you.