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导出文件
    简单例子
<?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配置文件##

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值