More explicit rule for ignoring empty placeholder cells in Excel ODS #184
This commit is contained in:
parent
3ee7099c95
commit
e60054f3c4
@ -20,6 +20,7 @@ class RowIterator implements IteratorInterface
|
|||||||
const XML_NODE_TABLE = 'table:table';
|
const XML_NODE_TABLE = 'table:table';
|
||||||
const XML_NODE_ROW = 'table:table-row';
|
const XML_NODE_ROW = 'table:table-row';
|
||||||
const XML_NODE_CELL = 'table:table-cell';
|
const XML_NODE_CELL = 'table:table-cell';
|
||||||
|
const MAX_COLUMNS_EXCEL= 16384;
|
||||||
|
|
||||||
/** Definition of XML attribute used to parse data */
|
/** Definition of XML attribute used to parse data */
|
||||||
const XML_ATTRIBUTE_NUM_COLUMNS_REPEATED = 'table:number-columns-repeated';
|
const XML_ATTRIBUTE_NUM_COLUMNS_REPEATED = 'table:number-columns-repeated';
|
||||||
@ -134,15 +135,16 @@ class RowIterator implements IteratorInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add value if the last read cell is not empty or does not need to repeat cell values.
|
// Only add the value if the last read cell is not a trailing empty cell repeater in Excel.
|
||||||
|
// The current count of read columns is determined my counting the the values in $rowData.
|
||||||
// This is to avoid creating a lot of empty cells, as Excel adds a last empty "<table:table-cell>"
|
// This is to avoid creating a lot of empty cells, as Excel adds a last empty "<table:table-cell>"
|
||||||
// with a number-columns-repeated value equals to the number of (supported columns - used columns).
|
// with a number-columns-repeated value equals to the number of (supported columns - used columns).
|
||||||
// In Excel, the number of supported columns is 16384, but we don't want to returns rows with always 16384 cells.
|
// In Excel, the number of supported columns is 16384, but we don't want to returns rows with
|
||||||
if (!$this->isEmptyCellValue($cellValue) || $numColumnsRepeated === 1) {
|
// always 16384 cells.
|
||||||
|
if ((count($rowData) + $numColumnsRepeated) !== self::MAX_COLUMNS_EXCEL) {
|
||||||
for ($i = 0; $i < $numColumnsRepeated; $i++) {
|
for ($i = 0; $i < $numColumnsRepeated; $i++) {
|
||||||
$rowData[] = $cellValue;
|
$rowData[] = $cellValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->numReadRows++;
|
$this->numReadRows++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user