Tag: 捆绑

在Symfony中使用liuggio / ExcelBundle清空PHPExcel文件

我有一些代码遍历Excel工作表的行和列,并用其他文本replace文本。 这是由具有excel文件和字典作为参数的服务完成的。 $mappedTemplate = $this->get('app.entity.translate')->translate($phpExcelObject, $dictionary); 服务本身看起来像这样。 public function translate($template, $dictionary) { foreach ($template->getWorksheetIterator() as $worksheet) { foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set foreach ($cellIterator as $cell) { if (!is_null($cell)) { if (!is_null($cell->getCalculatedValue())) { if (array_key_exists((string)$cell->getCalculatedValue(), $dictionary)) { $worksheet->setCellValue( $cell->getCoordinate(), $dictionary[$cell->getCalculatedValue()] ); […]