我有这个代码,我用它来将所有列A作为PHP数组:
<?php
include 'Classes\PHPExcel\IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load('keywords.xlsx');
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet
for( $i=2; $i<=$arrayCount; $i++ )
{
$value1 = trim($allDataInSheet[$i]["A"]);
var_dump($value1);
}
?>
它适用于一个Excel文件,该文件在A列上有一个数字列表:
输出示例:
string '111111' (length=6)
string '222222' (length=6)
string '333333' (length=6)
string '444444' (length=6)
string '555555' (length=6)
但是当我有一份文本清单时:
我收到错误:
(!)警告:array_keys()期望参数1为数组,在第3079行的C:\ wamp \ www \ PHPExcel \ Classes \ PHPExcel \ Calculation.php中给出整数
知道为什么会这样吗?
答案 0 :(得分:1)
您可以尝试rangeToArray()
$objPHPExcel->setActiveSheetIndex(0)->rangeToArray('A1:A15');