标签:creat __file__ value write log val load exce pex
把数据库的数据输出excel格式
利用phpexcel中的examples的01和07,对excel文件的读写
a.https://github.com/PHPOffice/PHPExcel下载
b.写文件
require_once ‘/Classes/PHPExcel.php‘; $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0) ->setCellValue(‘A1‘, ‘Hello‘) ->setCellValue(‘B2‘, ‘world!‘) ->setCellValue(‘C1‘, ‘Hello‘) ->setCellValue(‘D2‘, ‘world!‘); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel2007‘); $objWriter->save(str_replace(‘.php‘, ‘.xlsx‘, __FILE__));
c.读文件再写入
require_once ‘/Classes/PHPExcel.php‘; $objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue(‘A1‘, ‘Hello‘) ->setCellValue(‘B2‘, ‘world!‘) ->setCellValue(‘C1‘, ‘Hello‘) ->setCellValue(‘D2‘, ‘world!‘); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel2007‘); $objWriter->save(str_replace(‘.php‘, ‘.xlsx‘, __FILE__));
php对excel的操作还有其他的,遇到会慢慢记录在这。
标签:creat __file__ value write log val load exce pex
原文地址:http://www.cnblogs.com/norm/p/6220308.html