Saving a xls file

Topics: Developer Forum, Project Management Forum, User Forum
Dec 20, 2012 at 12:54 PM

I can write a file by doing many operation on the data and it.Now instead of saving a file in the cwd(), is there a way to provide a file as downloadable format. such that the user can save it any where as per his requirement.

Dec 20, 2012 at 4:32 PM

See in Tests\01simple-download-xls.php or Tests\01simple-download-xlsx.php

Dec 21, 2012 at 11:00 AM
Edited Dec 21, 2012 at 11:36 AM

If i save the file in ciw(), i don't see any issues but if i am trying to download the file using :

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="simple.xlsx"');
header('Cache-Control: max-age=0');

then i am able to get the option for downloading  the file. But after opening it is saying that :

"Excel cannot open the file '01simple.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file"


For xls, it is able to open the file simple.xls but the content is not clear there are special characters in the file(data is not as expected).

can you please help on this.

Dec 21, 2012 at 2:11 PM
Open the file with a text editor to look at if an error or debugging message is not present or, more difficult, parasitic characters (spaces, \n, ...). A xlsx must begin with PK (nothing before), a xls by DI (nothing before).
Even if it does not jump to the eyes, the problem is very often there.
Dec 24, 2012 at 5:43 AM

Thanks that help me alot to solve my issue.