如何使用PhpExcel将excel电子表格写入变量? [英] How do I write my excel spreadsheet into a variable, using PhpExcel?
本文介绍了如何使用PhpExcel将excel电子表格写入变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在用数据加载PHPExcel对象之后,我想直接将内容输出到php变量中,而不是写入文件中.我是否错过了执行此操作的方法,因为似乎唯一的保存方法是保存到磁盘.
After loading a PHPExcel object with my data, I want to output the contents directly into a php variable, instead of writing to a file. Have I missed the method to do that, for it seems that the only way to save is to save to disk.
推荐答案
您可以使用写入器将其保存到磁盘或保存到php://output.如果是后者,则可以使用输出缓冲来捕获该输出,然后将其存储在变量中....不确定为什么要这么做.
You can use a writer to save to disk, or save to php://output. If the latter, you could use output buffering to capture that output and then store in a variable.... not sure quite why you'd want to do this though.
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_start();
$objWriter->save('php://output');
$excelOutput = ob_get_clean();
这篇关于如何使用PhpExcel将excel电子表格写入变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文