Page 1 of 1
Writing to a saved file
Posted: Sat Mar 04, 2006 9:01 am
by falloutx
I know is it possible to generate a excel file from a SQL query. But I will like to know if I can use php to query from the database, then write it to a copy of an excel file that is already saved on the server.
I am having trouble figuring out how to create a copy of the saved file on the server.
Any help will be appreciated. Thanks in advance
Posted: Sat Mar 04, 2006 9:22 am
by feyd
copy()?
I'm going to assume you mean a CSV file. In that case,
fopen('filename', 'at') will allow you to open the file and append to it provided permissions allow it.
Posted: Sat Mar 04, 2006 9:24 am
by neophyte
I've never worked with excel spreadsheets and php but as far as copying goes have you tried:
http://us2.php.net/manual/en/function.copy.php
Posted: Sat Mar 04, 2006 2:20 pm
by falloutx
Sorry I did not make myself clear abt the format I was explaining.
I am not using CSV as it does not support many advance functions that I will like to save in the excel template on the server. I am trying to copy a bunch of data into a copied excel template which does chart generation using some macros.
Posted: Sat Mar 04, 2006 2:32 pm
by feyd
The only Excel format writer doesn't support the chart generation stuff, so it may break. And I don't think the reader is released as yet, or rather stable. The writer is on pear.php.net. The reader is under proposal on pear.php.net
Posted: Sun Mar 05, 2006 11:21 pm
by falloutx
Thanks for the help...
I am wondering if there is a possibility of downloading a file that is stored on the server without using ftp or any webserver management add on.
I tried the following, but it just creates a new excel file for download and not the data.xls that I have stored in the server.
Code: Select all
# file name for download
$filename = "data.xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
Posted: Sun Mar 05, 2006 11:35 pm
by feyd