Convert HTML file to Excel using PHPExcel

Hiren Patel picture Hiren Patel · Sep 18, 2014 · Viewed 23.2k times · Source

I have required to convert html file (test.html) to excel in PHPExcel

myhtml file text.html it is save test.php but containt of html

please idea how to implement in this

Answer

Mark Baker picture Mark Baker · Sep 18, 2014

You could simply read the documentation provided, but:

$inputFileType = 'HTML';
$inputFileName = './myHtmlFile.html';
$outputFileType = 'Excel2007';
$outputFileName = './myExcelFile.xlsx';

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

$objPHPExcelWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,$outputFileType);
$objPHPExcel = $objPHPExcelWriter->save($outputFileName);