Home > php教程 > php手册 > body text

phpExcel的使用方法及使用实例【超全】

WBOY
Release: 2016-06-07 11:37:10
Original
1439 people have browsed it

phpExcel的使用方法及使用实例【超全】
本文介绍php扩展phpexcel的使用方法及使用实例

首先到phpexcel官网上下载最新的phpexcel类,下周解压缩一个classes文件夹,里面包含了PHPExcel.php和PHPExcel的文件夹,这个类文件和文件夹是我们需要的,把classes解压到你项目的一个目录中,重名名为phpexcel,开始喽,(代码都摘自自带实例)<?php <br /> require_once './phpexcel/PHPExcel.php';<br>  <br> // 首先创建一个新的对象  PHPExcel object<br> $objPHPExcel = new PHPExcel();<br>  <br> // 设置文件的一些属性,在xls文件——>属性——>详细信息里可以看到这些值,xml表格里是没有这些值的<br> $objPHPExcel<br>       ->getProperties()  //获得文件属性对象,给下文提供设置资源<br>       ->setCreator( "Maarten Balliauw")                 //设置文件的创建者<br>       ->setLastModifiedBy( "Maarten Balliauw")          //设置最后修改者<br>       ->setTitle( "Office 2007 XLSX Test Document" )    //设置标题<br>       ->setSubject( "Office 2007 XLSX Test Document" )  //设置主题<br>       ->setDescription( "Test document for Office 2007 XLSX, generated using PHP classes.") //设置备注<br>       ->setKeywords( "office 2007 openxml php")        //设置标记<br>       ->setCategory( "Test result file");                //设置类别<br> // 位置aaa  *为下文代码位置提供锚<br> // 给表格添加数据<br> $objPHPExcel->setActiveSheetIndex(0)             //设置第一个内置表(一个xls文件里可以有多个表)为活动的<br>             ->setCellValue( 'A1', 'Hello' )         //给表的单元格设置数据<br>             ->setCellValue( 'B2', 'world!' )      //数据格式可以为字符串<br>             ->setCellValue( 'C1', 12)            //数字型<br>             ->setCellValue( 'D2', 12)            //<br>             ->setCellValue( 'D3', true )           //布尔型<br>             ->setCellValue( 'D4', '=SUM(C1:D2)' );//公式<br>  <br> //得到当前活动的表,注意下文教程中会经常用到$objActSheet<br> $objActSheet = $objPHPExcel->getActiveSheet();<br> // 位置bbb  *为下文代码位置提供锚<br> // 给当前活动的表设置名称<br> $objActSheet->setTitle('Simple2222');代码量有点大,大家直接去博客查看吧
以上为内容的部分截取
http://www.seo0395.com/archives-211

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!