页面指定部分的内容在客户端导出到word/excel文件中并打开该文件。求教思路如何?

解决方案 »

  1.   


    <?php
    //如果包含图片文字,还不如直接生成PDF。在PHP手册中你可以很方便地参考PDF函数。$file_type = "vnd.ms-excel";
    $file_name = "test";
    $file_ending = "xls";header("Content-Type: application/".$file_type);
    header("Content-Disposition: attachment; filename=".$file_name.".".$file_ending);
    header("Pragma: no-cache");
    header("Expires: 0");print("Hello World!\n");
    print("\n");print("Item Name\tColor\tNumber\n");
    print("TV\tBlack\t6\n");
    print("Book\tWhite\t88\n");
    ?>
      

  2.   

    如果要导出word里面包含样式和图片,很麻烦吗?
    我最近也遇到这个问题,我看见了一个,你可以参考,参考。http://www.cnitblog.com/CoffeeCat/archive/2009/04/08/47753.html用的时候注意编码
      

  3.   

    phpexcel这个软件很不错。配置好后可以利用函数直接生成excel,word和pdf,很方便的。
    你搜索下载一下。
    有问题再联系我。
    我已经配置成功并用的很好。
      

  4.   

    最笨的方法,你把php生成的html页面直接输出为word或者excel头。
    也可以输出为excel/wordheader("Content-Type: application/".$file_type);
    header("Content-Disposition: attachment; filename=".$file_name.".".$file_ending);
    header("Pragma: no-cache");
    header("Expires: 0");如果想excel好看,最好输出为table。