Bugfix: Patch 12318 - OOCalc cells containing <text:span> inside the <text:p> tag

Bugfix: Fix to listWorksheetInfo() method for OOCalc Reader

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@91446 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-06-07 19:42:45 +00:00
parent f65dbba088
commit ec9256a12e
2 changed files with 30 additions and 34 deletions

View File

@ -303,7 +303,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
$tmpInfo = array();
$tmpInfo['worksheetName'] = $worksheetDataAttributes['name'];
$tmpInfo['worksheetName'] = (string) $worksheetDataAttributes['name'];
$tmpInfo['lastColumnLetter'] = 'A';
$tmpInfo['lastColumnIndex'] = 0;
$tmpInfo['totalRows'] = 0;
@ -311,43 +311,16 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
$rowIndex = 0;
foreach ($worksheetData as $key => $rowData) {
$rowHasData = false;
switch ($key) {
case 'table-row' :
$columnIndex = 0;
foreach ($rowData as $key => $cellData) {
$cellHasData = false;
$cellDataText = $cellData->children($namespacesContent['text']);
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
if (isset($cellDataText->p)) {
switch ($cellDataOfficeAttributes['value-type']) {
case 'string' :
case 'boolean' :
case 'float' :
case 'date' :
case 'time' :
$cellHasData = true;
break;
}
}
$cellDataText = null;
$cellDataOfficeAttributes = null;
if ($cellHasData) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
$rowHasData = true;
}
++$columnIndex;
}
++$rowIndex;
if ($rowHasData) {
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
}
break;
}
}
@ -560,11 +533,31 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
}
if (isset($cellDataText->p)) {
// Consolodate if there are multiple p records (maybe with spans as well)
$dataArray = array();
// 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
// we have no way of knowing proper positioning anyway.
foreach ($cellDataText->p as $pData) {
if (isset($pData->span)) {
// span sections do not newline, so we just create one large string here
$spanSection = "";
foreach ($pData->span as $spanData) {
$spanSection .= $spanData;
}
array_push($dataArray, $spanSection);
} else {
array_push($dataArray, $pData);
}
}
$allCellDataText = implode($dataArray, "\n");
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
switch ($cellDataOfficeAttributes['value-type']) {
case 'string' :
$type = PHPExcel_Cell_DataType::TYPE_STRING;
$dataValue = $cellDataText->p;
$dataValue = $allCellDataText;
if (isset($dataValue->a)) {
$dataValue = $dataValue->a;
$cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
@ -573,7 +566,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
case 'boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($cellDataText->p == 'TRUE') ? True : False;
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
break;
case 'float' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;

View File

@ -28,6 +28,9 @@ Fixed in SVN:
rather than restricting to tcPDF
Current options are tcPDF, mPDF, DomPDF
tcPDF Library has now been removed from the deployment bundle
- Feature: (MBaker) Initial version of HTML Reader
- Bugfix: (cyberconte) Patch 12318 - OOCalc cells containing <text:span> inside the <text:p> tag
- Bugfix: (schir1964) Fix to listWorksheetInfo() method for OOCalc Reader
2012-05-19 (v1.7.7):