zoukankan      html  css  js  c++  java
  • Phpexcel使用

    在看正文之前,友情提示程序员兄弟(姐妹),尽量不要久坐,多起来走动走动咯。有个好身体,才能再干它20年嘛!

    前言

    之前在处理表格相关的需求时,写表格我用的table的方式,读的话我是先将excel文件转换成csv,然后根据行和“,”分隔符进行内容读取。但是这样不是很灵活,遇到一些特殊字符,像换行什么的,还容易出问题,所以今天就简单地学习了一下phpexcel。

    学习方法

    phpexcel的学习建议大家主要看这里:https://github.com/PHPOffice/PHPExcel ,然后再结合网上一些资料。

    安装

    安装方法在github的项目说明里有:

    install.txt的内容是:

    Requirements
    ------------
    
    The following requirements should be met prior to using PHPExcel:
    * PHP version 5.2.0 or higher
    * PHP extension php_zip enabled *)
    * PHP extension php_xml enabled
    * PHP extension php_gd2 enabled (if not compiled in)
    
    *) php_zip is only needed by PHPExcel_Reader_Excel2007, PHPExcel_Writer_Excel2007,
       PHPExcel_Reader_OOCalc. In other words, if you need PHPExcel to handle .xlsx or .ods
       files you will need the zip extension, but otherwise not.
    
    
    
    Installation instructions
    -------------------------
    
    Installation is quite easy: copy the contents of the Classes folder to any location
    in your application required.
    
    Example:
    
    If your web root folder is /var/www/ you may want to create a subfolder called
    /var/www/Classes/ and copy the files into that folder so you end up with files:
    
    /var/www/Classes/PHPExcel.php
    /var/www/Classes/PHPExcel/Calculation.php
    /var/www/Classes/PHPExcel/Cell.php
    ...
    
    
    
    Getting started
    ---------------
    
    A good way to get started is to run some of the tests included in the download.
    Copy the "Examples" folder next to your "Classes" folder from above so you end up with:
    
    /var/www/Examples/01simple.php
    /var/www/Examples/02types.php
    ...
    
    Start running the test by pointing your browser to the test scripts:
    
    http://example.com/Examples/01simple.php
    http://example.com/Examples/02types.php
    ...
    
    Note: It may be necessary to modify the include/require statements at the beginning of
    each of the test scripts if your "Classes" folder from above is named differently.

    使用

    写可以参考这个文件。读可以参考这个文件。

  • 相关阅读:
    修复UBUNTU的NetworkManager applet不见方法
    在 Windows下用 Visual Studio 编译 OpenSSL
    Linux下Firefox汉化方法
    查看SQL Server数据库表、索引视图等占用的空间大小
    Oracle Instant Client的安装和使用
    angular 单页应用程序实现浏览器后退按钮跳转到前一页面,优化用户体验
    十分钟彻底理解javascript 的 this指向,不懂请砸店
    提高前端生产力的小技巧:谷歌开发人员工具保存修改
    十分钟带你入门bootstrap
    做一个自己的字符图标
  • 原文地址:https://www.cnblogs.com/doubilaile/p/8309478.html
Copyright © 2011-2022 走看看