I'm using PHPExcel reader for read data from Exce file in my Yii2 application. This is the code that I've used:
$objPHPExcel = new \PHPExcel();
$fileName = Yii::getAlias('@webroot/trash/trash_vatout/') . $name;
$inputFiles = fopen(Yii::getAlias('@webroot/trash/trash_vatout/') . $name, "r");
try {
$inputFileType = \PHPExcel_IOFactory::identify($fileName);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($fileName);
} catch (Exception $ex) {
die('Error');
}
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestDataRow();
$highestColumn = $sheet->getHighestDataColumn();
$colNumber = PHPExcel_Cell::columnIndexFromString($highestColumn);
$col = $colNumber - 1;
$arrayData = [];
$bool1 = NULL; //first bool value
$bool2 = NULL; //second bool value
$bool3 = NULL; //third bool value
for ($row = 1; $row <= $highestRow; ++$row) {
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, $bool1, $bool2, $bool3);
if (!is_null($rowData[0][$col])) {
$arrayData[] = array_map(function($values) {
$tempArrayKey = [];
foreach ($values as $key => $value) {
$newKey = $key + 1;
$tempArrayKey[] = $newKey . '_' . $value;
}
return $tempArrayKey;
}, $rowData);
}
}
I used it following tutorial from some source.
In line code $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, $bool1, $bool2, $bool3);
, it has been set three boolean value. In my case I set them all as NULL.
Anyone knows what are the purpose of the bool value actually?
I've tried manytimes to read file, if I'm not wrong, the second bool value is set for read Excel Formula.
But how about the others?
Thanks.