有关在浏览器中显示Excel内容而不要求保存附件的问题 . 我可以通过附件打开excel文件下载 . 但无法在浏览器中显示它 .
$writer = new PHPExcel_Writer_Excel2007($spreadsheet);
//$writer = PHPExcel_IOFactory::createWriter();
ob_end_clean();
header('Content-Type: application/vnd.openxmlformats- officedocument.spreadsheetml.sheet');
ob_end_clean();
$writer->save('php://output');
exit;
@helicera:您需要为文件名提供xlsx扩展名 . - 艾伦1月18日在7:05
但是在删除 Headers 后我可以在哪里提供xlsx扩展名('Content-Disposition:attachment; filename =“report.xlsx”');线?
========================从加载excel ==================
error_reporting(E_STRICT);
require_once 'PHPExcel.php';
require_once 'PHPExcel/Writer/Excel2007.php';
require_once 'PHPExcel/IOFactory.php';
$inputFileName = 'example.xls';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('example.html');
?>