当我使用PHPExcel类读取ods文件(xls和xlsx没问题)时,两个单元格在一起并包含相同的数据,第二个单元格变成空白,这是一个错误吗?这是我的代码:
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../../Librerias/phpexcel/Classes/');
include 'PHPExcel/IOFactory.php';
$input_fileName = dirname(__FILE__) . '/bug.ods';
$input_file_type = PHPExcel_IOFactory::identify($input_fileName);
$reader = PHPExcel_IOFactory::createReader($input_file_type);
$reader->setReadDataOnly(true);
$objPHPExcel = $reader->load($input_fileName);
$objPHPExcel->setActiveSheetIndex(0);
$rowIterator = $objPHPExcel->getActiveSheet()->getRowIterator();
$array_data = array();
foreach($rowIterator as $row){
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
$rowIndex = $row->getRowIndex ();
foreach ($cellIterator as $cell) {
$array_data[$rowIndex][$cell->getColumn()] = $cell->getCalculatedValue();
}
}
echo '<pre>' ; print_r($array_data); echo '</pre>' ;
&GT;
以下是bug.ods的内容
| A | B | C | D | E | F
-----------------------------------------------
1 | 1 | 1 | 2 | 2 | 3 | 3
2 | 2 | 2 | 1 | 1 | 3 | 3
3 | 3 | 3 | 1 | 1 | 2 | 2
4 | a | a | b | b | c | c
5 | b | b | a | a | c | c
6 | c | c | a | a | b | b
...这是print_r输出。
Array
(
[1] => Array
(
[A] => 1
[B] =>
[C] => 2
[D] =>
[E] => 3
)
[2] => Array
(
[A] => 2
[B] =>
[C] => 1
[D] =>
[E] => 3
)
[3] => Array
(
[A] => 3
[B] =>
[C] => 1
[D] =>
[E] => 2
)
[4] => Array
(
[A] => a
[B] =>
[C] => b
[D] =>
[E] => c
)
[5] => Array
(
[A] => b
[B] =>
[C] => a
[D] =>
[E] => c
)
[6] => Array
(
[A] => c
[B] =>
[C] => a
[D] =>
[E] => b
)
)
我做错了吗?这是一个错误吗?
有些想法?
答案 0 :(得分:0)
PHPExcel问题跟踪器上的问题: http://phpexcel.codeplex.com/workitem/17471 这固定为两个值,但如果值重复而不是两次问题