
Originariamente inviata da
fermat
questo è un esempio che ho scritto sul mio blog.
però parte dal fatto che il file è già sul server, quindi aggiungerci l'upload:
Codice PHP:
<?php
include_once './PHPExcel/IOFactory.php'
$inputFileName = './barre.xls';
?>
<table class="table table-bordered">
<?php
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$phpExcel = $objReader->load($inputFileName);
$sheet = $phpExcel->getSheet(0);
} catch (Exception $e) {
echo $e->getMessage();
}
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
for ($row = 1; $row <= $highestRow; $row++):
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
?>
<tr>
<?php foreach ($rowData[0] as $col): ?>
<td><?php echo $col; ?></td>
<?php endforeach; ?>
</tr>
<?php endfor; ?>
</table>
vedi se può esserti utile!