是否可以使用 PHPExcel 编辑上传的 xlsx 文件?我可以使用此功能读取上传的文件:
<?php
require_once('Classes/PHPExcel.php');
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("Ataskaita2.xlsx");
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
echo '<table border=1>' . "\n";
foreach ($objWorksheet->getRowIterator() as $row) {
echo '<tr>' . "\n";
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
echo '<td>' . $cell->getValue() . '</td>' . "\n";
}
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
?>
但我还需要编辑这些单元格有没有办法在文本字段中显示这些单元格并在编辑后将其保存回来?谢谢你的建议!