Read XLXS file using PHP
After install Composer and XLSXREADER call below file at top.
require('./XLSXReader.php');
Use any ExcelSheet for example..
Add any Excel file in root of the project directory. So, we can use it latter.
Create index.php file and add below code.
<?php require('./XLSXReader.php'); $targetPath = './hello world.xlsx'; $xlsx = new XLSXReader($targetPath); $sheetNames = $xlsx->getSheetNames(); $imports=array(); $html=""; foreach($sheetNames as $sheetName) { $sheet = $xlsx->getSheet($sheetName); echo "<h3>".$sheet->sheetName."</h3>"; $html.="<table border='1'>"; foreach($sheet->getData() as $row) { $html.="<tr>"; foreach($row as $key){ $html.="<td>".$key."</td>"; } $html.="<tr>"; } $html.="</table>"; } echo $html;
Run it on your local or server. For more about demo and output visit at programmerdesk
The above is the detailed content of Read XLXS file in PHP and display header.. For more information, please follow other related articles on the PHP Chinese website!