【发布时间】:2014-07-31 10:00:23
【问题描述】:
如何使用 PHPExcel 逐行读取 Excel 工作表?我有一张包含超过 100000 行的工作表,但我只想读取 500 行。
$sheetData = $objPHPExcel->getActiveSheet();
$highestRow = $sheetData->getHighestRow();
$highestColumn = $sheetData->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
echo '<table>';
for ($row = 1; $row <= $highestRow; ++$row) {
echo '<tr>';
for ($col = 0; $col <= $highestColumnIndex; ++$col) {
echo '<td>' . $sheetData->getCellByColumnAndRow($col, $row)->getValue() . '</td>';
}
echo '</tr>';
}
echo '</table>';
【问题讨论】: