官网地址:http://phpexcel.codeplex.com/

 

安装

1. 安装 php_zip 扩展 

# pecl install zip

 

在 php.ini 中添加扩展

extension = "zip.so" 

 

2. 安装 PHPExcel 库文件

# ls
PHPExcel  PHPExcel.php
# cp -rf * /usr/local/php/lib/php/PEAR/

 

 

示例 

<?php
error_reporting(E_ALL);

require_once 'PHPExcel/IOFactory.php';

$file = "./example.xlsx";

$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);

$objPHPExcel = $objReader->load($file);

$objPHPExcel->setActiveSheetIndex(0);

$objWorksheet = $objPHPExcel->getActiveSheet();

$highestRow = $objWorksheet->getHighestRow(); // e.g. 10
$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5

for ($row = 1; $row <= $highestRow; ++$row) {
  for ($col = 0; $col <= $highestColumnIndex; ++$col) {
    echo $objWorksheet->getCellByColumnAndRow($col$row)->getCalculatedValue() . ' ';
  }

  echo "\n";
}
echo "\n";
?> 

 

 

相关文章:

  • 2021-12-20
  • 2022-12-23
  • 2022-02-12
  • 2021-07-06
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
相关资源
相似解决方案