PHP open excel file in browser

how to open excel file in browser,

I donโ€™t want something like a force loading dialogue,

I want to open excel in somthing browser, like in gmail, when you click the excel file in your inbox, it will show the browser itself,

same thing as doing it in php.

+7
php com
source share
1 answer

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, not 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; 
+10
source share

All Articles