//导出
public function excelMultiSheetData($datas,$titlename,$title,$filename){
$str = "<?xml version=\"1.0\"?>";
$str .= "<?mso-application progid=\"Excel.Sheet\"?>";
$str .= "<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\">";
$str .= "<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">";
$str .= "<Author>HCZY</Author>";
$str .= "<Created>".time()."</Created>";
$str .= "</DocumentProperties>";
foreach ($datas as $key=> $sheet )
{
$str .= "<Worksheet ss:Name=\"".$key."\">";
$str .= "<Table>";
$str .= "<head>".$titlename."</head>";
foreach ($sheet as $row )
{
$str .= "<Row>";
foreach ( $row as $k => $v )
{
$v=$v?$v:'';
$str .= "<Cell><Data ss:Type=\"String\">{$v}</Data></Cell>";
}
$str .= "</Row>";
}
$str .= "</Table>";
$str .= "</Worksheet>";
}
$str .= "</Workbook>";
header( "Content-Type: application/vnd.ms-excel; name='excel'" );
header( "Content-type: application/octet-stream" );
header( "Content-Disposition: attachment; filename=".$filename );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
exit( $str );
}
excel导出php导出多工作薄excel表导出xml -- ECstore
最新推荐文章于 2024-05-06 18:16:21 发布