douzong3599 2016-06-13 07:38
浏览 188

使用PHP的Excel文件适用于Mac数字和Windows excel

I have created a simple script using PHP header by which I am creating excel document which is working fine for MS Excel in windows and MAC OS.

below is the code

<?php 
$Timestamp = date("d-m-Y");
header('Content-type: application/excel');                                  
header('Content-Disposition: attachment; filename="Estimates-'.$Timestamp.'.xls"');
 <table class="table" width="800px">

   <tr>
    <th style="background-color: #666666; color:#ffffff; width:690px" align="left">Names</th>
    <th style="background-color: #666666; color:#ffffff; width:110px" >Bonus Amount</th>
   </tr>
<tbody>
  <tr>
    <td >Praveen Solanki</td>
    <td >45000</td>
   </tr>
  <tr>
    <td >Pramit Solanki</td>
    <td >30000</td>
   </tr> 
  <tr>
    <td >Ashish Surawanshi</td>
    <td >30000</td>
   </tr>
</tbody>
</table>

But when i open the same file in MAC machine using "NUMBERS" application, it is showing me my above html code. Because "NUMBERS" doesnt support this formatting which i found by R&D.

But now the question is how can i create the excel file which should work on NUMBERS plus MS EXCEL. As in my search i also found that the default document which i am creating directly form the MS Excel is currently opening on NUMBERS.

Looking for the correct path/code by which i can create the excel file.

  • 写回答

1条回答 默认 最新

  • dourao1877 2016-06-14 20:01
    关注

    https://github.com/PHPOffice/PHPExcel

    This library is what you need. It has the option to export as both .xls and .xlsx, and supports all sorts of formatting the Object Oriented Style.

    Most Office Suites now support .xlsx but if it doesn't work out for you, switch to .xls, which is almost universally compatible.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?