mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 14:56:04 +03:00
Feature: Work item 14301 - PHPExcel_Worksheet->toArray() is returning truncated values
I've made some modifications so that it is possible to pass a number of additional arguments to the method to determine exactly how the data is returned: @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 $returnColumnRef False - Return columns indexed by number (0..x); True - Return columns indexed by column ID (A..x) git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@61373 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
f93fde9b38
commit
32b8b1c7ab
@ -2115,11 +2115,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
/**
|
||||
* Create array from worksheet
|
||||
*
|
||||
* @param mixed $nullValue Value treated as "null"
|
||||
* @param boolean $calculateFormulas Should formulas be calculated?
|
||||
* @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 $returnColumnRef False - Return columns indexed by number (0..x)
|
||||
* True - Return columns indexed by column ID (A..x)
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($nullValue = null, $calculateFormulas = true) {
|
||||
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnColumnRef = false) {
|
||||
// Returnvalue
|
||||
$returnValue = array();
|
||||
|
||||
@ -2136,25 +2139,27 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
// Loop through cells
|
||||
for ($row = $dimension[0][1]; $row <= $dimension[1][1]; ++$row) {
|
||||
for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) {
|
||||
$columnRef = ($returnColumnRef) ? PHPExcel_Cell::stringFromColumnIndex($column) : $column;
|
||||
// Cell exists?
|
||||
if ($this->cellExistsByColumnAndRow($column, $row)) {
|
||||
$cell = $this->getCellByColumnAndRow($column, $row);
|
||||
|
||||
if ($cell->getValue() instanceof PHPExcel_RichText) {
|
||||
$returnValue[$row][$column] = $cell->getValue()->getPlainText();
|
||||
$returnValue[$row][$columnRef] = $cell->getValue()->getPlainText();
|
||||
} else {
|
||||
if ($calculateFormulas) {
|
||||
$returnValue[$row][$column] = $cell->getCalculatedValue();
|
||||
$returnValue[$row][$columnRef] = $cell->getCalculatedValue();
|
||||
} else {
|
||||
$returnValue[$row][$column] = $cell->getValue();
|
||||
$returnValue[$row][$columnRef] = $cell->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||
|
||||
$returnValue[$row][$column] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$row][$column], $style->getNumberFormat()->getFormatCode());
|
||||
if ($formatData) {
|
||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||
$returnValue[$row][$columnRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$row][$columnRef], $style->getNumberFormat()->getFormatCode());
|
||||
}
|
||||
} else {
|
||||
$returnValue[$row][$column] = $nullValue;
|
||||
$returnValue[$row][$columnRef] = $nullValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ Fixed in SVN:
|
||||
- Feature: (MBaker) Support for Extended and User-defined Workbook Properties in Excel2007 Writer
|
||||
- Feature: (MBaker) Provided a setGenerateSheetNavigationBlock(false); option to suppress generation of the sheet navigation block when writing multiple worksheets to HTML
|
||||
- Feature: (MBaker) Advanced Value Binder now recognises TRUE/FALSE strings (locale-specific) and converts to boolean
|
||||
- Feature: (MBaker) Work item 14301 - PHPExcel_Worksheet->toArray() is returning truncated values
|
||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Percent
|
||||
- Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php
|
||||
- Bugfix: (Progi1984) Workitem 7895 - Excel5 : Formula : Error constant
|
||||
|
Loading…
Reference in New Issue
Block a user