PHPExcel库的奇怪行为

时间:2012-08-09 23:32:03

标签: php phpexcel

我遇到了PHPExcel lib的奇怪行为(我之前从未使用过它)。我有这样的代码:

$inputFileName = 'excel.ods';
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

我不知道Arrray方法究竟做了什么,因为我找不到任何这方面的文件。我认为当excel文件有一些空白单元格时会出现问题 - 它们不会被复制,但是下一个单元格会在它们的位置或类似物中被篡改。有人可以提供我的文档来运行到Array? (我认为这些参数有问题)。

提前谢谢你:)

PS:它是来自示例的代码

1 个答案:

答案 0 :(得分:2)

toArray()从工作表中的每个单元格中获取数据并将其放入PHP数组中

/**
 * Create array from worksheet
 *
 * @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
 */
  

PHPExcel的文档位于文件夹/ Documentation中。   API文档位于/ Documentation / API中   示例位于文件夹/测试和/文档/示例

当前1.7.7版本中存在一个错误,当工作表中有空白单元格时,该错误可能会错误对齐从ods文件中读取的单元格。这个错误已在github上的最新代码中修复。

相关问题