PHPExcel阅读器中三个布尔值的用途是什么?
我正在使用phpexcelreader从我的Yii2应用程序中的EXE文件读取数据。 这是我使用的代码:PHPExcel阅读器中三个布尔值的用途是什么?,excel,yii2,phpexcel,phpexcelreader,Excel,Yii2,Phpexcel,Phpexcelreader,我正在使用phpexcelreader从我的Yii2应用程序中的EXE文件读取数据。 这是我使用的代码: $objPHPExcel = new \PHPExcel(); $fileName = Yii::getAlias('@webroot/trash/trash_vatout/') . $name; $inputFiles = fopen(Yii::getAlias('@webroot/trash/trash_vatout/') . $name, "r");
$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);
}
}
$objPHPExcel=new\PHPExcel();
$fileName=Yii::getAlias(“@webroot/trash/trash\u vatout/”)$名称
$inputFiles=fopen(Yii::getAlias('@webroot/trash/trash\u vatout/')。$name,“r”);
试一试{
$inputFileType=\PHPExcel\u IOFactory::identify($fileName);
$objReader=\PHPExcel\u IOFactory::createReader($inputFileType);
$objPHPExcel=$objReader->load($fileName);
}捕获(例外$ex){
死亡(“错误”);
}
$sheet=$objPHPExcel->getSheet(0);
$highestRow=$sheet->getHighestDataRow();
$highestColumn=$sheet->getHighestDataColumn();
$colNumber=PHPExcel_单元::columnIndexFromString($highestColumn);
$col=$colNumber-1;
$arrayData=[];
$bool1=NULL//第一布尔值
$bool2=NULL//第二布尔值
$bool3=NULL//第三布尔值
对于($row=1;$row RANGETORRAY('A'.$row'.:'.$HIGHEST COLUMN.$row、$bool1、$bool2、$bool3));
如果(!为null($rowData[0][$col])){
$arrayData[]=数组映射(函数($values){
$tempArrayKey=[];
foreach($key=>$value的值){
$newKey=$key+1;
$tempArrayKey[]=$newKey..'.$value;
}
返回$tempArrayKey;
}数据);
}
}
我在一些来源的教程中使用了它。
在行代码$rowData=$sheet->rangeToArray('A'.$row'.:'.$highestColumn.$row,$bool1,$bool2,$bool3);
中,它被设置为三个布尔值。在我的例子中,我将它们都设置为NULL
有人知道布尔值的实际用途吗?
我已经多次尝试读取文件,如果我没有错的话,第二个bool值被设置为读取Excel公式
但是其他的呢
谢谢。签名是
所以
-混合$bool1
如果单元格不存在,则在数组项中返回值(可以是任何数据类型/值)$nullValue
-布尔$bool2
应该计算公式吗$calculateFormulas
-布尔$bool3
是否应将格式应用于单元格值$formatData
/**
* Create array from a range of cells
*
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
* @param mixed $nullValue Value returned in the array entry if a cell doesn't exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
*/