Forum Moderators: coopster

Message Too Old, No Replies

export to excel save / email

exporting to excel, saving or emailing the file

         

simonha

11:26 am on Oct 2, 2007 (gmt 0)

10+ Year Member



My first post - php newbie, so appreciate your support.

I'm currently using headers to save web page as excel file.

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

I want to be able to save a copy to the server or email a copy?
Not sure what I need to change or add to achieve this?

Have looked around and tried searching on here? - can't see the search threads feature if there is one?

Many thanks.

joelgreen

2:53 pm on Oct 2, 2007 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, simonha!

Please clarify what you mean by "want to save a web page as Excel file".

Are you trying to save HTML page as excel file?

simonha

6:51 am on Oct 3, 2007 (gmt 0)

10+ Year Member



Yes, sorry - should have made that clear.
Thanks.

jatar_k

2:24 pm on Oct 3, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld simonha,

but you can't actually save html as excel, they aren't the same thing. If it was some table data that you wanted to save you could try saving as a CSV file which can be opened in excel.

there is a function here
[webmasterworld.com...]

simonha

8:29 pm on Oct 6, 2007 (gmt 0)

10+ Year Member



I know how to create an excel file based on a table I dynamically create using html / data from a db query no probs. The issue I have is, rather than hitting the save button, I want to automatically send in an email or save a copy on the server to reference via a link perhaps.

It's for a pricing system, with quotes being generated by employees and partners. The materials management team want to see the quotes that are being generated.

Thanks.

PHP_Chimp

1:05 pm on Oct 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are already using a database for this project couldn't you store the quotes in that as well?
You could write the excel file to the server then get the file read and put into html so that it can be looked at, but this seems a little redundant if you already have a database.
As im assuming that your quotes are only valid for a certain number of days. So if you have a quote table with customer, whatever fields you need for an invoice, date created then you can automatically stop quotes from being retrieved for prices that are months/years out of date. If you write the files to the server then unless you are going to run some job to remove files older than 30 days or whatever your limit is then they will just sit there until someone personally sites down and removes them.

If you want to write the files to the server, as opposed to your database, then have a look at fopen [uk3.php.net], fwrite [uk3.php.net] and fread [uk3.php.net].

If you want to use the last modified date on the server to stop people from accessing quotes that are older than a certian date then look at getlastmod [uk3.php.net]. However this returns the last time the page was modified not the date that the quote was originally saved, so you would need to check if that is a good enough way of limiting access to old quotes.

simonha

3:14 pm on Oct 8, 2007 (gmt 0)

10+ Year Member



Thanks for this, although the problem is I don't know how to write it to the server. The quotes are dynamically created pulling data from a number of different tables, considering a number of elements that provide a solution price.

I can create an excel file using the header, and on the client side the user can choose to save / open. I want to be able to save the file on the server and provide a link to it, for materials management, when they look through the quotes exported table, (I create a record each time a quote is exported with just summary cost information - I can manage this!)

I've spent so long trying to find an answer to what I thought was a simple question. How do I save an excel file to the server that's created based on headers OR if this is not possible, what other methods are there to take a snap-shot of the quote page (HTML) that was dynamically created for reference later?

Thanks for you help.