简体   繁体   中英

how to export the selected data into excel format when i click the link

how to save a selected data in excel format in php when i click the link? and i want to save the file in the location given at the run time of the file? please advice me..

header('Content-Type: application/vnd.ms-excel');   //define header info for browser
    header('Content-Disposition: attachment; 
    filename='.$dbTable.'-'.date('Ymd').'.xls');
    header('Pragma: no-cache');
    header('Expires: 0');

Try this :

header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: inline; filename=\"" . $dbTable.'-'.date('Ymd') . ".xls\"");
header("Pragma: no-cache");
header("Expires: 0");

Or simply :

header("Location: http://path/to/file/filename.xlsx");
/* Make sure that code below does not get executed when we redirect. */
exit;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM