PHP excel模板

把模板保存为xls


<?php echo '<?xml version="1.0"?>';?>

<?php echo '<?mso-application progid="Excel.Sheet"?>';?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Version>12.00</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <DownloadComponents/>
  <RemovePersonalInformation/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>4530</WindowHeight>
  <WindowWidth>8505</WindowWidth>
  <WindowTopX>480</WindowTopX>
  <WindowTopY>120</WindowTopY>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="宋体" x:CharSet="134"/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
  <Style ss:ID="s62">
   <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Color="#FFFFFF"/>
   <Interior ss:Color="#333399" ss:Pattern="Solid"/>
  </Style>
  <Style ss:ID="s65">
   <NumberFormat ss:Format="#,##0.00_ "/>
  </Style>
  <Style ss:ID="s67">
   <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
  </Style>
  <Style ss:ID="s68">
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
   </Borders>
  </Style>


  <Style ss:ID="s69">
   <Borders>
    <Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
   </Borders>
   <NumberFormat ss:Format="#,##0.00_ "/>
  </Style>


  <Style ss:ID="s72">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Size="18"/>
  </Style>
 </Styles>
 <Worksheet ss:Name="Sheet1">
  <Table ss:ExpandedRowCount="99999" x:FullColumns="1"
   x:FullRows="1" ss:DefaultColumnWidth="120" ss:DefaultRowHeight="18">
   <Column ss:AutoFitWidth="0"/>
   <Column ss:AutoFitWidth="0" />
   <Column ss:AutoFitWidth="0" />
   <Column ss:AutoFitWidth="0" />


   <Row ss:AutoFitHeight="0" ss:Height="28">
    <Cell ss:MergeAcross="5" ss:StyleID="s72"><Data ss:Type="String">详细消费记录</Data></Cell>
   </Row>
   
   <Row ss:AutoFitHeight="0">
    <Cell><Data ss:Type="String">开始时间:</Data></Cell>
    <Cell><Data ss:Type="String"><?php echo $startDay;?></Data></Cell>
    <Cell><Data ss:Type="String">结束时间:</Data></Cell>
    <Cell><Data ss:Type="String"><?php echo $endDay;?></Data></Cell>
   </Row>
   
   <Row ss:AutoFitHeight="0">
    <Cell ss:StyleID="s62"><Data ss:Type="String">消费时间</Data></Cell>
    <Cell ss:StyleID="s62"><Data ss:Type="String">用户名</Data></Cell>
    <Cell ss:StyleID="s62"><Data ss:Type="String">国籍</Data></Cell>
    <Cell ss:StyleID="s62"><Data ss:Type="String">金额(元)</Data></Cell>
   </Row>


   <?php foreach($dataList as $vo){?>
   <Row ss:AutoFitHeight="0">
    <Cell ss:StyleID="s68"><Data ss:Type="String"><?php echo date('Y-m-d H:i:s', $vo['time']);?></Data></Cell>
    <Cell ss:StyleID="s68"><Data ss:Type="String"><?php echo $vo['name'];?></Data></Cell>
    <Cell ss:StyleID="s69"><Data ss:Type="String" ><?php echo $vo['value'];?></Data></Cell>
    <Cell ss:StyleID="s69"><Data ss:Type="String" ><?php echo $vo['coin'];?></Data></Cell>
  </Row>
   <?php }?>
  </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
   <Unsynced/>
   <Selected/>
   <Panes>
    <Pane>
     <Number>3</Number>
     <ActiveRow>1</ActiveRow>
     <ActiveCol>1</ActiveCol>
    </Pane>
   </Panes>
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>

</Workbook>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值