Export .xlsx With Phpspreadsheet Reading A .php File That Creates An Html Table
Is it possible to create an .xlsx spreadsheet using PHPSpreadsheet from a .php file that creates an HTML table? The .php file creates an HTML table from both POST and DB values. I'
Solution 1:
You have 2 ways to do this :
- continue to generate your xlsx from the HTML generated by your php script.
In this way, your PHP script generates (for instance) an export.html file on the disk, and then phpspreadsheet code reads this file (with "HTML Reader") and generates the xslx.
With PHPExcel (prior name of phpspreadsheet), we did like this :
$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);
- instead of generating an HTML, you can generate a CSV for your PHP code, and then send it to phpspreadsheet, see the documentation here https://phpspreadsheet.readthedocs.io/en/develop/topics/reading-files/
Post a Comment for "Export .xlsx With Phpspreadsheet Reading A .php File That Creates An Html Table"