Merge branch 'master' into update_doc_number_format
This commit is contained in:
commit
1b658cb822
@ -14,7 +14,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.0",
|
"php": ">=7.2.0",
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"ext-xmlreader" : "*"
|
"ext-xmlreader": "*",
|
||||||
|
"ext-dom": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8",
|
"phpunit/phpunit": "^8",
|
||||||
|
@ -122,10 +122,15 @@ class CellValueFormatter
|
|||||||
*/
|
*/
|
||||||
protected function formatInlineStringCellValue($node)
|
protected function formatInlineStringCellValue($node)
|
||||||
{
|
{
|
||||||
// inline strings are formatted this way:
|
// inline strings are formatted this way (they can contain any number of <t> nodes):
|
||||||
// <c r="A1" t="inlineStr"><is><t>[INLINE_STRING]</t></is></c>
|
// <c r="A1" t="inlineStr"><is><t>[INLINE_STRING]</t><t>[INLINE_STRING_2]</t></is></c>
|
||||||
$tNode = $node->getElementsByTagName(self::XML_NODE_INLINE_STRING_VALUE)->item(0);
|
$tNodes = $node->getElementsByTagName(self::XML_NODE_INLINE_STRING_VALUE);
|
||||||
$cellValue = $this->escaper->unescape($tNode->nodeValue);
|
|
||||||
|
$cellValue = '';
|
||||||
|
for ($i = 0; $i < $tNodes->count(); $i++) {
|
||||||
|
$tNode = $tNodes->item($i);
|
||||||
|
$cellValue .= $this->escaper->unescape($tNode->nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
return $cellValue;
|
return $cellValue;
|
||||||
}
|
}
|
||||||
|
@ -186,18 +186,22 @@ class CellValueFormatterTest extends TestCase
|
|||||||
public function testFormatInlineStringCellValue($value, $expectedFormattedValue)
|
public function testFormatInlineStringCellValue($value, $expectedFormattedValue)
|
||||||
{
|
{
|
||||||
$nodeListMock = $this->createMock(\DOMNodeList::class);
|
$nodeListMock = $this->createMock(\DOMNodeList::class);
|
||||||
|
$nodeListMock
|
||||||
|
->expects($this->atLeastOnce())
|
||||||
|
->method('count')
|
||||||
|
->willReturn(1);
|
||||||
$nodeListMock
|
$nodeListMock
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('item')
|
->method('item')
|
||||||
->with(0)
|
->with(0)
|
||||||
->will($this->returnValue((object) ['nodeValue' => $value]));
|
->willReturn((object) ['nodeValue' => $value]);
|
||||||
|
|
||||||
$nodeMock = $this->createMock(\DOMElement::class);
|
$nodeMock = $this->createMock(\DOMElement::class);
|
||||||
$nodeMock
|
$nodeMock
|
||||||
->expects($this->atLeastOnce())
|
->expects($this->atLeastOnce())
|
||||||
->method('getElementsByTagName')
|
->method('getElementsByTagName')
|
||||||
->with(CellValueFormatter::XML_NODE_INLINE_STRING_VALUE)
|
->with(CellValueFormatter::XML_NODE_INLINE_STRING_VALUE)
|
||||||
->will($this->returnValue($nodeListMock));
|
->willReturn($nodeListMock);
|
||||||
|
|
||||||
$formatter = new CellValueFormatter(null, null, false, false, new Escaper\XLSX());
|
$formatter = new CellValueFormatter(null, null, false, false, new Escaper\XLSX());
|
||||||
$formattedValue = \ReflectionHelper::callMethodOnObject($formatter, 'formatInlineStringCellValue', $nodeMock);
|
$formattedValue = \ReflectionHelper::callMethodOnObject($formatter, 'formatInlineStringCellValue', $nodeMock);
|
||||||
|
@ -72,6 +72,19 @@ class ReaderTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testReadShouldSupportInlineStringsWithMultipleValueNodes()
|
||||||
|
{
|
||||||
|
$allRows = $this->getAllRowsForFile('sheet_with_multiple_value_nodes_in_inline_strings.xlsx');
|
||||||
|
|
||||||
|
$expectedRows = [
|
||||||
|
['VALUE 1 VALUE 2 VALUE 3 VALUE 4', 's1 - B1'],
|
||||||
|
];
|
||||||
|
$this->assertEquals($expectedRows, $allRows);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -299,17 +299,6 @@ class WriterTest extends TestCase
|
|||||||
}
|
}
|
||||||
$this->assertEquals(',', \localeconv()['decimal_point']);
|
$this->assertEquals(',', \localeconv()['decimal_point']);
|
||||||
|
|
||||||
$cellValue = 1234.5;
|
|
||||||
var_dump("Cell value before: " . $cellValue);
|
|
||||||
$cellValue = str_replace(
|
|
||||||
[\localeconv()['thousands_sep'], \localeconv()['decimal_point']],
|
|
||||||
['', '.'],
|
|
||||||
$cellValue
|
|
||||||
);
|
|
||||||
var_dump("Cell value after: " . $cellValue);
|
|
||||||
var_dump("Thousands sep: " . \localeconv()['thousands_sep']);
|
|
||||||
var_dump("Decimal point: " . \localeconv()['decimal_point']);
|
|
||||||
|
|
||||||
$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
|
$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
|
||||||
$dataRows = $this->createRowsFromValues([
|
$dataRows = $this->createRowsFromValues([
|
||||||
[1234.5],
|
[1234.5],
|
||||||
|
@ -414,16 +414,6 @@ class WriterTest extends TestCase
|
|||||||
}
|
}
|
||||||
$this->assertEquals(',', \localeconv()['decimal_point']);
|
$this->assertEquals(',', \localeconv()['decimal_point']);
|
||||||
|
|
||||||
var_dump("Cell value before: " . $valueToWrite);
|
|
||||||
$cellValue = str_replace(
|
|
||||||
[\localeconv()['thousands_sep'], \localeconv()['decimal_point']],
|
|
||||||
['', '.'],
|
|
||||||
$valueToWrite
|
|
||||||
);
|
|
||||||
var_dump("Cell value after: " . $cellValue);
|
|
||||||
var_dump("Thousands sep: " . \localeconv()['thousands_sep']);
|
|
||||||
var_dump("Decimal point: " . \localeconv()['decimal_point']);
|
|
||||||
|
|
||||||
$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
|
$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
|
||||||
$dataRows = $this->createRowsFromValues([
|
$dataRows = $this->createRowsFromValues([
|
||||||
[$valueToWrite],
|
[$valueToWrite],
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user