how to export excel file in same server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stareagle
Forum Newbie
Posts: 3
Joined: Sun Jan 10, 2010 5:39 am

how to export excel file in same server

Post by stareagle »

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

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

$filename="sms.xls";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.ms-excel");
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header);
header("Content-Transfer-Encoding: binary");
@readfile($file);

I want to be able to save a copy to the server not to opening dialog save?
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.
gavin1996
Forum Newbie
Posts: 22
Joined: Tue Jan 30, 2007 8:30 pm

Re: how to export excel file in same server

Post by gavin1996 »

:D :D

you should using fwrite function.

Code: Select all

 
<?php
$filename = '123.xls';
$handle = @fopen($filename,'w+');
$a= "hello?world"."\t";
$a.= "world"."\t";
$a.= "\t\n";
$a.= "this is second line"."\t";
fwrite( $handle , $a );
fclose;
?>
 
 
PS: I am a PHPER form China , if you still have any question about it,
you can Add my MSN: gavin_blazepro*msn.cn ( * is @ )
stareagle
Forum Newbie
Posts: 3
Joined: Sun Jan 10, 2010 5:39 am

Re: how to export excel file in same server

Post by stareagle »

thanks gavin1996 for ur reply
this code i used to extract data from HTML code which content tables and other data in to excel file my real problem in it this page contain images which not extract into excel file so i need from this code

$filename="sms.xls";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.ms-excel");
$header="Content-Disposition: attachment; filename=".$filename.";";
header($header);
header("Content-Transfer-Encoding: binary");

do not open dialog save for user but directly save file in local server
and Not sure what I need to change or add to achieve this?
Attachments
RepExport1.zip
simple code
(2.1 KiB) Downloaded 64 times
Post Reply