I am trying to open an existing excel file, modify some cells and save it. I am using Excel2007 to read and write.
The input file has a size of about 1 MB and has several formulas, protected data and hidden rows and columns and sheets, which I do not change.
I can load the data and read and write to it some values that I check with various var_dumps in the code.
The problem is its conservation. It generates some fatal errors in timeouts, and also, if it writes a file, the file size is inflated to 9.2 MB, and it is normal if I can open it.
a piece of code - nothing unusual.
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($inputFile);
$objPHPExcel->setActiveSheetIndex(2);
$activeSheet = $objPHPExcel->getActiveSheet();
$currCell = $activeSheet->getCell("O3");
$cellValidation = $currCell->getDataValidation("O3");
$values = array();
if ($cellValidation->getShowDropDown() == true)
{
$values = $cellValidation->getFormula1();
$valArray = explode(",", $values);
$currCell->setValue($valArray[0]);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter -> setPreCalculateFormulas(false);
$objWriter->save($outputFile);
I use MS Excel 2010 to open the resulting file, but it just takes forever and did not open it even once.
, , , .
.