用于读/写MS Excel文件的PHP库?

时间:2022-09-15 16:29:33

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.

是否有免费的PHP库来读取/写入excel文件?我不想使用XML(我认为你可以将excel文件读作XML,我不想这样做)。我还需要创建图形和其他好东西,因此将文件保存为csv也不起作用。

4 个解决方案

#1


4  

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

也许http://phpexcel.codeplex.com/正是您要找的?

#2


0  

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

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

#3


0  

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

您必须下载该库,然后使用下面的代码来读取/写入图表的Excel: -

http://phpexcel.codeplex.com/

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');
?>

#4


0  

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

我建议使用MS-Excel Stream Handler PHP类,这是一流的*库:)

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

有一篇很棒的文章解释如何通过php代码读/写excel文件。

#1


4  

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

也许http://phpexcel.codeplex.com/正是您要找的?

#2


0  

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

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

#3


0  

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

您必须下载该库,然后使用下面的代码来读取/写入图表的Excel: -

http://phpexcel.codeplex.com/

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');
?>

#4


0  

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

我建议使用MS-Excel Stream Handler PHP类,这是一流的*库:)

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

有一篇很棒的文章解释如何通过php代码读/写excel文件。