Merge branch 'master' into feature/num_format
This commit is contained in:
commit
7baf54915b
@ -15,10 +15,13 @@ tools:
|
|||||||
php_pdepend: true
|
php_pdepend: true
|
||||||
php_loc:
|
php_loc:
|
||||||
enabled: true
|
enabled: true
|
||||||
excluded_dirs: [vendor, tests]
|
filter:
|
||||||
php_cpd:
|
paths: ['src']
|
||||||
|
php_cpd: false # Must be disabled to use php_sim instead
|
||||||
|
php_sim:
|
||||||
enabled: true
|
enabled: true
|
||||||
excluded_dirs: [vendor, tests]
|
filter:
|
||||||
|
paths: ['src']
|
||||||
|
|
||||||
build_failure_conditions:
|
build_failure_conditions:
|
||||||
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9
|
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9
|
||||||
|
@ -252,6 +252,17 @@ class GlobalFunctionsHelper
|
|||||||
header($string);
|
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()
|
* Wrapper around global function iconv()
|
||||||
* @see iconv()
|
* @see iconv()
|
||||||
|
@ -24,6 +24,7 @@ class CellValueFormatter
|
|||||||
const XML_NODE_P = 'p';
|
const XML_NODE_P = 'p';
|
||||||
const XML_NODE_S = 'text:s';
|
const XML_NODE_S = 'text:s';
|
||||||
const XML_NODE_A = 'text:a';
|
const XML_NODE_A = 'text:a';
|
||||||
|
const XML_NODE_SPAN = 'text:span';
|
||||||
|
|
||||||
/** Definition of XML attribute used to parse data */
|
/** Definition of XML attribute used to parse data */
|
||||||
const XML_ATTRIBUTE_TYPE = 'office:value-type';
|
const XML_ATTRIBUTE_TYPE = 'office:value-type';
|
||||||
@ -104,7 +105,7 @@ class CellValueFormatter
|
|||||||
$spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C);
|
$spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C);
|
||||||
$numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1;
|
$numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1;
|
||||||
$currentPValue .= str_repeat(' ', $numSpaces);
|
$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;
|
$currentPValue .= $childNode->nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,10 @@ abstract class AbstractWriter implements WriterInterface
|
|||||||
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
|
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
|
||||||
$this->throwIfFilePointerIsNotAvailable();
|
$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
|
// Set headers
|
||||||
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
|
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
|
||||||
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
|
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
|
||||||
@ -238,7 +242,8 @@ abstract class AbstractWriter implements WriterInterface
|
|||||||
public function addRows(array $dataRows)
|
public function addRows(array $dataRows)
|
||||||
{
|
{
|
||||||
if (!empty($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');
|
throw new InvalidArgumentException('The input should be an array of arrays');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,6 +468,20 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($expectedRows, $allRows, 'Text in hyperlinks should be read');
|
$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 string $fileName
|
||||||
* @param bool|void $shouldFormatDates
|
* @param bool|void $shouldFormatDates
|
||||||
|
BIN
tests/resources/ods/sheet_with_inline_font_formatting.ods
Normal file
BIN
tests/resources/ods/sheet_with_inline_font_formatting.ods
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user