php html 模板输出 excel 例子

php代码部分

<?php

$table  = "<table>";
$table .= "<thead><tr><td>表头1</td><td>表头2</td><td>表头3</td></tr></thead>";
$table .= "<tbody><tr><td>内容1</td><td>内容2</td><td>内容3</td></tr></tbody>";
$table .= "</table>";

$this->assign('table',$table);
$this->display('excel');

?>

html部分

<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<!--[if gte mso 9]-->
<xml>
     <x:ExcelWorkbook>
        <x:ExcelWorksheets>
            <x:ExcelWorksheet>
                <x:Name>sheet1</x:Name>
                <x:WorksheetOptions>
                      <x:Print>
                          <x:ValidPrinterInfo />
                      </x:Print>
                </x:WorksheetOptions>
            </x:ExcelWorksheet>
         </x:ExcelWorksheets>
     </x:ExcelWorkbook>
</xml>
<!--[endif]-->
</head>
<body>
<table>
  {{$trs}}
</table>
 </body>
</html>

猜你喜欢

转载自blog.csdn.net/zalion/article/details/52448615