Skip to content
Advertisement

PhpExcel write/save onto existing excel file

First of all, I have searched for my problem in both stackoverflow and on the forms, but I could not find exact question and its solution. (This one is about saving HTML to existing Excel)

*** I have also seen some answers on related question about saving as new excel file, but my question is can I save onto existing excel file and if it is possible why I am getting an error when I open it.

QUESTION:

I have an existing excel-2010 template file with stock codes and dates.

enter image description here

I load/read this file with PHPexcel (read/load works fine) and I fill up with price values on some empty cells, then I am trying to save the file back with below code.

JavaScript

After saving, I am getting below error (“Excel cannot open the file because the file format or file extension is not valid … “) enter image description here

Advertisement

Answer

excel5 is for xls ( excel2007 is for xlsx)

Hence, change the write to excel block to

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement