dporb84480 2013-05-01 21:21
浏览 156
已采纳

如何使用PHP浏览HTML表并获取每个td中的数据?

I am trying to use the PHPExcel class to export reports into excel file. What I really need to do is to go thru every row in the HTML table then place it into cells in an excel file.

I think PHPExcel has enough document to help me with created the excel file. But what I am not sure on how to do is to take an html table and break it so I can take every value and put it in an excel cell.

Thanks for your help

  • 写回答

3条回答 默认 最新

  • dongmo2324 2013-05-01 22:55
    关注

    As simple as:

    $objReader = PHPExcel_IOFactory::createReader('HTML');
    $objPHPExcel = $objReader->load("myHtmlFile.html");
    
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save("myExcelFile.xlsx");
    

    but you could use your same basic logic for building the HTML from your report data, and just modify it to set cell values in a PHPExcel object. If you have an MVC, then its only the View that you really need to change.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?