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条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料