From 70c81e809f9b31b628b3bbbaad17464339749d45 Mon Sep 17 00:00:00 2001
From: Pavel Zyukin
Date: Fri, 3 Jun 2016 19:09:37 +0400
Subject: [PATCH 1/4] Add the ability to pass an array with various keys to
addRows() (#240)
---
src/Spout/Writer/AbstractWriter.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Spout/Writer/AbstractWriter.php b/src/Spout/Writer/AbstractWriter.php
index effa45b..e5f9ad7 100644
--- a/src/Spout/Writer/AbstractWriter.php
+++ b/src/Spout/Writer/AbstractWriter.php
@@ -238,7 +238,8 @@ abstract class AbstractWriter implements WriterInterface
public function addRows(array $dataRows)
{
if (!empty($dataRows)) {
- if (!is_array($dataRows[0])) {
+ $firstRow = reset($dataRows);
+ if (!is_array($firstRow)) {
throw new InvalidArgumentException('The input should be an array of arrays');
}
From cd38ba093e80908867aa0df29d980330c96f0194 Mon Sep 17 00:00:00 2001
From: madflow
Date: Wed, 8 Jun 2016 18:50:00 +0200
Subject: [PATCH 2/4] Fix #245 (#246)
---
.../Reader/ODS/Helper/CellValueFormatter.php | 3 ++-
tests/Spout/Reader/ODS/ReaderTest.php | 14 ++++++++++++++
.../ods/sheet_with_inline_font_formatting.ods | Bin 0 -> 8552 bytes
3 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 tests/resources/ods/sheet_with_inline_font_formatting.ods
diff --git a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
index 38c1c85..99d8563 100644
--- a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
+++ b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
@@ -24,6 +24,7 @@ class CellValueFormatter
const XML_NODE_P = 'p';
const XML_NODE_S = 'text:s';
const XML_NODE_A = 'text:a';
+ const XML_NODE_SPAN = 'text:span';
/** Definition of XML attribute used to parse data */
const XML_ATTRIBUTE_TYPE = 'office:value-type';
@@ -104,7 +105,7 @@ class CellValueFormatter
$spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C);
$numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1;
$currentPValue .= str_repeat(' ', $numSpaces);
- } else if ($childNode->nodeName === self::XML_NODE_A) {
+ } else if ($childNode->nodeName === self::XML_NODE_A || $childNode->nodeName === self::XML_NODE_SPAN) {
$currentPValue .= $childNode->nodeValue;
}
}
diff --git a/tests/Spout/Reader/ODS/ReaderTest.php b/tests/Spout/Reader/ODS/ReaderTest.php
index 759d842..dee4164 100644
--- a/tests/Spout/Reader/ODS/ReaderTest.php
+++ b/tests/Spout/Reader/ODS/ReaderTest.php
@@ -468,6 +468,20 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedRows, $allRows, 'Text in hyperlinks should be read');
}
+ /**
+ * @return void
+ */
+ public function testReaderShouldReadInlineFontFormattingAsText()
+ {
+ $allRows = $this->getAllRowsForFile('sheet_with_inline_font_formatting.ods');
+
+ $expectedRows = [
+ ['I am a yellow bird']
+ ];
+
+ $this->assertEquals($expectedRows, $allRows, 'Text formatted inline should be read');
+ }
+
/**
* @param string $fileName
* @param bool|void $shouldFormatDates
diff --git a/tests/resources/ods/sheet_with_inline_font_formatting.ods b/tests/resources/ods/sheet_with_inline_font_formatting.ods
new file mode 100644
index 0000000000000000000000000000000000000000..60d4eee4347db40a654eae0ce16bc59163173dfa
GIT binary patch
literal 8552
zcmeHsby$>J*Zv3+DoBVRB_N12NJ&X|cS#Q|!vI4_N+>Bvha!S>H%NDll)%uffOK~}
z-*C?BtLMCWuJ`xn@4LP=*Ap}IthJxL_TKls*ILSQs8>$=E3mPn71Wm1+18W=Y7Dc2u|Vz2Y)zqHCy1G?BMZ#V!OYkc
zW@%>TsQee3sKdo5W@sSL<#7jTQ{B=DVq$A-Wdmb%{C>+~XKN9ptSE(jo#Z<55o{T0
zaaH6MKpx*PQITgNwB`vA2o_B7bVHo)iktCyZpevSYj0s!&=U;+R(0ALRQ
zo?-qzfx*G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hs{kI>HyZn50
zIqMcS+^Ho3$qAF}o}54)ovUuXd!QTv=c@zKmXcIep6lU;^z;vVZ0k24_h9Mf9W-h2
zcYeLcJ+Dw7e7(PY*mx$euSe>fMf20xy*rNNxT~cq*q+ivm3a44!~DstIIl>TA|76;
z_#6xBJh7+~WY@1Hy#gyv)X=K$bEG|73ng(
zrJUhB3Qsk1%~ex{8|jXt6e+8v*;L&3NU={Mc(0I9)Ii;aHt0vP8>NjIA21b8w&;qH
zVBBXduY^*8=js8J+M^b^^3iQKwd`6Hg^gC#fBoXquSfi}sb#i3&!+2m^Z4xbYEwwM
zZ|YT@#Ij1vTX7D-U6al@xHuZDnZ_(bg@s1P*q1(*YbP9|Li$(&89*t^T|prL{l3PD
zbo5X1z2ff2gPi6
zJN&<}^E2=KY3KW7ylnqFd0aBj4}tx{&Tn|=pC-UxI|=`V(Vto9_no}tp&x>RH2e37
z^dGGB*Pi|ixqn@DLP%r(Mpqp@myrBJyhwio(8_XX$W0RngopgtA@OJa
Hk6H6SyF#aN
literal 0
HcmV?d00001
From 8edd8e24016945d5d2b6838ac838f78ed2644c56 Mon Sep 17 00:00:00 2001
From: Adrien Loison
Date: Wed, 8 Jun 2016 13:53:41 -0700
Subject: [PATCH 3/4] Clear previous output when openToBrowser() called (#243)
If any character has been outputted before, the generated file will be corrupted.
---
src/Spout/Common/Helper/GlobalFunctionsHelper.php | 11 +++++++++++
src/Spout/Writer/AbstractWriter.php | 4 ++++
2 files changed, 15 insertions(+)
diff --git a/src/Spout/Common/Helper/GlobalFunctionsHelper.php b/src/Spout/Common/Helper/GlobalFunctionsHelper.php
index 1d660c1..dd4356e 100644
--- a/src/Spout/Common/Helper/GlobalFunctionsHelper.php
+++ b/src/Spout/Common/Helper/GlobalFunctionsHelper.php
@@ -252,6 +252,17 @@ class GlobalFunctionsHelper
header($string);
}
+ /**
+ * Wrapper around global function ob_end_clean()
+ * @see ob_end_clean()
+ *
+ * @return void
+ */
+ public function ob_end_clean()
+ {
+ ob_end_clean();
+ }
+
/**
* Wrapper around global function iconv()
* @see iconv()
diff --git a/src/Spout/Writer/AbstractWriter.php b/src/Spout/Writer/AbstractWriter.php
index e5f9ad7..46f47cc 100644
--- a/src/Spout/Writer/AbstractWriter.php
+++ b/src/Spout/Writer/AbstractWriter.php
@@ -121,6 +121,10 @@ abstract class AbstractWriter implements WriterInterface
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
$this->throwIfFilePointerIsNotAvailable();
+ // Clear any previous output (otherwise the generated file will be corrupted)
+ // @see https://github.com/box/spout/issues/241
+ $this->globalFunctionsHelper->ob_end_clean();
+
// Set headers
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
From dc31d6e8c2127d54fc1f4950a847fd0955d617af Mon Sep 17 00:00:00 2001
From: Adrien Loison
Date: Thu, 9 Jun 2016 10:52:01 -0700
Subject: [PATCH 4/4] Update .scrutinizer.yml (#248)
---
.scrutinizer.yml | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 9794aff..42f2492 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -15,10 +15,13 @@ tools:
php_pdepend: true
php_loc:
enabled: true
- excluded_dirs: [vendor, tests]
- php_cpd:
+ filter:
+ paths: ['src']
+ php_cpd: false # Must be disabled to use php_sim instead
+ php_sim:
enabled: true
- excluded_dirs: [vendor, tests]
+ filter:
+ paths: ['src']
build_failure_conditions:
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9