Excel is prompting to save changes on document created with PHPExcel

Topics: Developer Forum
Jul 5, 2011 at 11:10 AM
Edited Jul 5, 2011 at 11:12 AM

Hi Everyone,

Firstly, sorry in advance if this issue has been addressed before.
I am currently using PHPExcel to open a "template" xlsx file, modify the value of some cells, then save the file as a new name. This all works fine - the file is created normally. However, if I open the new file in Excel, then try to exit WITHOUT making any changes, Excel prompts me to save the changes. There were no changes made though... Just tried open and close it strait away...

Here is my code:


include 'Classes/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("template.xlsx");

->setCellValue("E1", "QUOTE  ".$_POST['quote']."\nPrepared by " . $_POST['salesperson'])
->setCellValue("B6", $_POST['customer'])
->setCellValue("B7", $_POST['address'])
->setCellValue("B9", $_POST['phone1'])
->setCellValue("B10", $_POST['email'])
->setCellValue("E7", $_POST['site'])
->setCellValue("E9", $_POST['phone2'])
->setCellValue("E10", $_POST['ubf_ref'])
->setCellValue("A12", $_POST['a1'])
->setCellValue("A13", $_POST['a2'])
->setCellValue("A14", $_POST['a3'])
->setCellValue("A15", $_POST['a4'])
->setCellValue("A16", $_POST['a5'])
->setCellValue("A17", $_POST['a6'])
->setCellValue("A18", $_POST['a7'])
->setCellValue("A19", $_POST['a8'])
->setCellValue("F12", $_POST['v1'])
->setCellValue("F13", $_POST['v2'])
->setCellValue("F14", $_POST['v3'])
->setCellValue("F15", $_POST['v4'])
->setCellValue("F16", $_POST['v5'])
->setCellValue("F17", $_POST['v6'])
->setCellValue("F18", $_POST['v7'])
->setCellValue("F19", $_POST['v8'])
->setCellValue("B20", $_POST['b1'])
->setCellValue("B21", $_POST['b2'])
->setCellValue("B22", $_POST['b3'])
->setCellValue("F20", $_POST['v9'])
->setCellValue("F21", $_POST['v10'])
->setCellValue("F22", $_POST['v11'])
->setCellValue("C23", $_POST['c1'])
->setCellValue("C24", $_POST['c2'])
->setCellValue("F23", $_POST['v12'])
->setCellValue("F24", $_POST['v13'])
->setCellValue("B25", $_POST['b4'])
->setCellValue("B27", $_POST['b5'])
->setCellValue("B28", $_POST['b6'])
->setCellValue("F26", $_POST['v14'])
->setCellValue("F27", $_POST['v15'])
->setCellValue("F29", $_POST['deposit']);


$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');



Hopefully someone can work this out. I've been pulling my hair out over it. Thanks in advance.


Jul 5, 2011 at 11:29 AM
Edited Jul 5, 2011 at 11:29 AM

Just in addition to this, i DO NOT use NOW() or TODAY() functions. I do however use simple cell addition and subtraction. eg  A1+A2  and SUM(A1:A5)