【发布时间】:2015-08-25 12:08:11
【问题描述】:
我下载了 phpexcel 库。我想要做的很简单:打开同一目录中的 .xls 文件,读取特定单元格并将值保存为变量(单元格中只有字母和数字)。
到目前为止我所拥有的:
<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
/** Include PHPExcel */
require_once dirname(__FILE__) . '/PHPExcel_1.8.0_doc/Classes /PHPExcel.php';
$inputFileName = 'inventory.xls';
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
// Get cell B8
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(0, 2)->getValue();
?>
【问题讨论】:
-
所以将
getValue()调用的结果分配给一个变量....$variableWhereYouWantToStoreTheValue = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow(0, 2)->getValue();这真的是 PHP 101 -
我很抱歉,我不知道我怎么会这么愚蠢xDD谢谢你一吨^^
标签: php cell phpexcel import-from-excel