Reputation: 5808
I have this code that I'm using to get all column A as a PHP array:
<?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);
}
?>
It works on one Excel file that has a list of numbers on column A:
Example of an output:
string '111111' (length=6)
string '222222' (length=6)
string '333333' (length=6)
string '444444' (length=6)
string '555555' (length=6)
But when I have a list of texts:
I get an error:
( ! ) Warning: array_keys() expects parameter 1 to be array, integer given in C:\wamp\www\PHPExcel\Classes\PHPExcel\Calculation.php on line 3079
Any idea why this is happening?
Upvotes: 1
Views: 9914
Reputation: 38584
You can try rangeToArray()
$objPHPExcel->setActiveSheetIndex(0)->rangeToArray('A1:A15');
Upvotes: 1