PHPExcel(更新中)

写在前面:

PHPExcel is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.

这是个十分强大的插件,有很多功能,下面是它所支持的.
Reading

  • BIFF 5-8 (.xls) Excel 95 and above
  • Office Open XML (.xlsx) Excel 2007 and above
  • SpreadsheetML (.xml) Excel 2003
  • Open Document Format/OASIS (.ods)
  • Gnumeric
  • HTML
  • SYLK
  • CSV

Writing

  • BIFF 8 (.xls) Excel 95 and above
  • Office Open XML (.xlsx) Excel 2007 and above
  • HTML
  • CSV
  • PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)

相关要求

  • PHP version 5.2.0 or higher
  • PHP extension php_zip enabled (required if you need PHPExcel to handle .xlsx .ods or .gnumeric files)
  • PHP extension php_xml enabled
  • PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
    使用PHPexcel导出文件
    导出excel步骤

    简单例子
<?php
/**
 * Created by Zoe.
 * User: Administrator
 * Date: 2017/2/8
 * Time: 9:16
 */
$dir = dirname(__FILE__);//find the path of current script
require_once '../Classes/PHPExcel.php';//use the file
$objPHPExcel = new PHPExcel();//实例化=>new excel in desk
$objSheet = $objPHPExcel->getActiveSheet();//获得当前活动sheet的操作对象
$objSheet->getTitle("demo");//set name
//$objSheet->setCellValue("A1","姓名")->setCellValue("B1","分数");//fill data
//$objSheet->setCellValue("A2","小啦虎")->setCellValue("B2","88");//fill data
$array = array(
    array("","name","score"),
    array("","Zoe","100"),
    array("","John","99")
);
$objSheet->fromArray($array);//直接加载数据块来填充数据
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,"Excel2007");//按照指定格式生成excel文件
$objWriter ->save($dir."/demo_1.xlsx");//save file

推荐使用setCellValue.

MYSQL配置文件##

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容