开发者

PHP library for reading/writing MS Excel files?

Is there a free PHP library for reading/writing excel files? I don't want to use XML (I think you could read excel files as XML, 开发者_开发百科I don't want to do it that way). I also need to create graphs and other goodies, so saving the file as csv will not work either.


Perhaps http://phpexcel.codeplex.com/ is what you're looking for?


http://pear.php.net/package/Spreadsheet_Excel_Writer


You have to download the library and then use below code to read/write excel with charts :-

http://phpexcel.codeplex.com/

<?php 
error_reporting(E_ALL);
date_default_timezone_set('Europe/London');
require_once '../Classes/PHPExcel/IOFactory.php';
require_once '../Classes/PHPExcel.php';
$excel2 = PHPExcel_IOFactory::createReader('Excel2007');

/*Enable chart read on excel*/
$excel2->setIncludeCharts(TRUE);
/*Enable chart read on excel*/

$excel2 = $excel2->load('excelname.xlsx'); // Empty Sheet

/*update cell data if you required */
$excel2->getActiveSheet()->setCellValue('B6', '2');
$excel2->getActiveSheet()->setCellValue('B7', '1');
$excel2->getActiveSheet()->setCellValue('B8', '3');
/*-----------------------------*/

$objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007');
/*Enable chart write on excel*/
$objWriter->setIncludeCharts(TRUE);
/*Enable chart write on excel*/
$objWriter->save('excelout.xlsx');
?>


I would recommend to use MS-Excel Stream Handler PHP class, which is one of the top class library for that :)

There is a great article to explain how to read/write excel files through php code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜