accessing ->save() data as a data stream?

Topics: Developer Forum
Dec 4, 2012 at 4:41 PM

I wondering if it is possbile to access the data created by phpexcel as a data stream, such as

$excel_data = $objWriter->save();

I realize I could write the data to a file and then read the file, but I am trying to avoid that step.

Dec 4, 2012 at 4:57 PM
If you do not want to write the file, so you want to send it directly to the browser?
If so, the save method accepts a particular parameter ' php://output' that does exactly this.
You can find a complete sample in Tests\01-simple-download - xlsx.php
Dec 4, 2012 at 8:58 PM

No, I'm trying to capture the data without sending it to the browser.

Dec 4, 2012 at 9:05 PM

Basic PHP (but not recommended because of the memory overheads)

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$excelOutput = ob_get_clean();

though I can't really see a business case for it... what do you plan on doing with the content once you've got it in a PHP string variable?

Dec 5, 2012 at 8:28 PM

I have an application that sends out e-mails, including attachments. The source of attachment information is a variable in my code, which is then fed to my email function. I was hoping to add the ability to send an Excel attachment type if the user chose to do so. Thus my desire to capture the data in a php variable.