开发者

php open excel file in browser

开发者 https://www.devze.com 2023-01-19 04:48 出处:网络
how to open excel file in browser , i do开发者_开发问答nt want some thing like force download dialog ,

how to open excel file in browser ,

i do开发者_开发问答nt want some thing like force download dialog ,

i want to open excel in browser somthing like in gmail when u click the excel file in the inbox, it will show browser itself,

same like , how to do in php.


Using PHPExcel:

include 'PHPExcel/IOFactory.php';
$inputFileType = 'Excel5';
$inputFileName = 'MyExcelFile.xls';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;

EDIT

If your Excel file is Excel 2007 (xlsx) or later rather than Excel 2003 (xls) or earlier

include 'PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = 'MyExcelFile.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;
0

精彩评论

暂无评论...
验证码 换一张
取 消