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.
how to export excel file in same server
Moderator: General Moderators
Re: how to export excel file in same server
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;
?>
you can Add my MSN: gavin_blazepro*msn.cn ( * is @ )
Re: how to export excel file in same server
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?
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