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 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100