Hum... A small example easy, directly from the documentation (4.5.5):
The type of input file can be changed as needed (type known by a test or determined by the method PHPExcel_IOFactory identify() upstream).
Only data is read (setReadDataOnly), this reduces the resources needed but in return, certain data (date, time) are less easy to interpreted.
There are other ways to do, difficulties can appear, but rather than rewrite documentation - that is freely available for everyone - we will see those you'll be faced.
<?php
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("test.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow(); // e.g. 10
$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5
echo '<table>' . "\n";
for ($row = 1; $row <= $highestRow; ++$row) {
echo '<tr>' . "\n";
for ($col = 0; $col <= $highestColumnIndex; ++$col) {
echo '<td>' . $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() . '</td>' . "\n";
}
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
?>
It shows the course of all cells in a worksheet, without the use of iterators. The contents of cells are displayed, but you can easily store it in a table instead.The type of input file can be changed as needed (type known by a test or determined by the method PHPExcel_IOFactory identify() upstream).
Only data is read (setReadDataOnly), this reduces the resources needed but in return, certain data (date, time) are less easy to interpreted.
There are other ways to do, difficulties can appear, but rather than rewrite documentation - that is freely available for everyone - we will see those you'll be faced.