Ods reader: few readability tweaks

This commit is contained in:
Paolo Agostinetto 2017-02-18 21:10:06 +01:00
parent 1667056515
commit 4cf7beef31
1 changed files with 27 additions and 20 deletions

View File

@ -459,7 +459,8 @@ class Ods extends BaseReader implements IReader
switch ($key) {
case 'table-header-rows':
/// TODO :: Figure this out. This is only a partial implementation I guess.
// ($rowData it's not used at all)
// ($rowData it's not used at all and I'm not sure that PHPExcel
// has an API for this)
// foreach ($rowData as $keyRowData => $cellData) {
// $rowData = $cellData;
@ -531,6 +532,7 @@ class Ods extends BaseReader implements IReader
// Consolidate if there are multiple p records (maybe with spans as well)
$dataArray = [];
// Text can have multiple text:p and within those, multiple text:span.
// text:p newlines, but text:span does not.
// Also, here we assume there is no text data is span fields are specified, since
@ -639,6 +641,7 @@ class Ods extends BaseReader implements IReader
$temp = explode('"', $cellDataFormula);
$tKey = false;
foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) {
@ -658,6 +661,7 @@ class Ods extends BaseReader implements IReader
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"', $temp);
}
@ -732,10 +736,13 @@ class Ods extends BaseReader implements IReader
$columnTo = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnIndex);
}
$rowTo = $rowID;
if ($cellData->hasAttributeNS($tableNs, 'number-rows-spanned')) {
$rowTo = $rowTo + (int)$cellData->getAttributeNS($tableNs, 'number-rows-spanned') - 1;
}
$cellRange = $columnID . $rowID . ':' . $columnTo . $rowTo;
$spreadsheet->getActiveSheet()->mergeCells($cellRange);
}