views:

223

answers:

1

I'm using a simple web-based PHP application that outputs a table as a spreadsheet

header("Content-Disposition: attachment; filename=" . $filename . ".xls");
header("Content-Type: application/vnd.ms-excel");

//inserts tab delimited text

But I'm finding the downloaded spreadsheet opens as a read-only file and must be saved locally and (in Excel on Windows) the type changed to XLS (from HTML). Is there a way to set the attribute of filetype correctly so that doing a simple save doesn't require correcting the filetype?

Is the file downloaded read-only by nature of security or is this not normal?

Also I don't like the automatic borders created when opening the spreadsheet in Excel or OpenOffice (on Linux). I would prefer to have no border formatting. Is there a way in the file to specify no added formatting or is this built into those applications?

+1  A: 

AFAIK, at least on Windows, it depends on what the user does with the prompt shown by the browser when they follow the link.

If the user chooses to save the file, it won't be read-only. If the user chooses to open it, the file will be saved to a temporary directory and the browser may remove it when it is closed. I am not sure how this mechanism works, but I am assuming there is a lock involved some place that makes the file read only.

Sinan Ünür