Skip to content

Commit 312cd5a

Browse files
authored
Merge branch 'master' into atsign
2 parents a084e7d + fcf03b9 commit 312cd5a

File tree

20 files changed

+326
-52
lines changed

20 files changed

+326
-52
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ and this project adheres to [Semantic Versioning](https://semver.org).
4141
- Problem rendering line chart with missing plot label. [PR #4074](https://github.com/PHPOffice/PhpSpreadsheet/pull/4074)
4242
- More RTL in Xlsx/Html Comments [Issue #4004](https://github.com/PHPOffice/PhpSpreadsheet/issues/4004) [PR #4065](https://github.com/PHPOffice/PhpSpreadsheet/pull/4065)
4343
- Empty String in sharedStrings. [Issue #4063](https://github.com/PHPOffice/PhpSpreadsheet/issues/4063) [PR #4064](https://github.com/PHPOffice/PhpSpreadsheet/pull/4064)
44+
- Xlsx Writer RichText and TYPE_STRING. [Issue #476](https://github.com/PHPOffice/PhpSpreadsheet/issues/476) [PR #4094](https://github.com/PHPOffice/PhpSpreadsheet/pull/4094)
45+
- Ods boolean data. [Issue #460](https://github.com/PHPOffice/PhpSpreadsheet/issues/460) [PR #4093](https://github.com/PHPOffice/PhpSpreadsheet/pull/4093)
46+
- Html Writer Minor Fixes. [PR #4089](https://github.com/PHPOffice/PhpSpreadsheet/pull/4089)
47+
- Changes to INDEX function. [Issue #64](https://github.com/PHPOffice/PhpSpreadsheet/issues/64) [PR #4088](https://github.com/PHPOffice/PhpSpreadsheet/pull/4088)
48+
- Ods Reader and Whitespace Text Nodes. [Issue #804](https://github.com/PHPOffice/PhpSpreadsheet/issues/804) [PR #4087](https://github.com/PHPOffice/PhpSpreadsheet/pull/4087)
49+
- Ods Xml Reader and Whitespace Text Nodes. [Issue #804](https://github.com/PHPOffice/PhpSpreadsheet/issues/804) [PR #4087](https://github.com/PHPOffice/PhpSpreadsheet/pull/4087)
4450
- Treat invalid formulas as strings. [Issue #1310](https://github.com/PHPOffice/PhpSpreadsheet/issues/1310) [PR #4073](https://github.com/PHPOffice/PhpSpreadsheet/pull/4073)
4551

4652
## 2024-05-11 - 2.1.0

docs/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ allow you to read and write various spreadsheet file formats such as Excel and L
2020
|CSV |||
2121
|PDF (using either the TCPDF, Dompdf or mPDF libraries, which need to be installed separately)| ||
2222

23+
Note - reading or writing certain aspects of a spreadsheet may not be supported in all formats. For more details, please consult
24+
[Features Cross-reference](./references/features-cross-reference.md).
25+
2326
# Getting started
2427

2528
## Software requirements

docs/references/features-cross-reference.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<td style="text-align: center; color: green;">✔</td>
2929
<td style="text-align: center; color: green;">✔</td>
3030
<td style="text-align: center; color: orange;">●</td>
31-
<td style="text-align: center; color: orange;">●</td>
31+
<td style="text-align: center; color: orange;">● <a href="#footnote6"><sup>6</sup></a></td>
3232
<td style="text-align: center; color: green;">✔</td>
3333
<td style="text-align: center;">N/A</td>
3434
<td style="text-align: center;">N/A</td>
@@ -389,7 +389,7 @@
389389
</tr>
390390
<tr>
391391
<td style="padding-left: 0.5em;"><strong>Conditional Formatting</strong></td>
392-
<td style="text-align: center; color: orange;"></td>
392+
<td style="text-align: center; color: green;"></td>
393393
<td style="text-align: center; color: green;">✔</td>
394394
<td style="text-align: center; color: red;">✖</td>
395395
<td style="text-align: center; color: red;">✖</td>
@@ -414,7 +414,7 @@
414414
<td style="text-align: center; color: green;">✔</td>
415415
<td style="text-align: center; color: green;">✔</td>
416416
<td style="text-align: center; color: green;">✔</td>
417-
<td style="text-align: center; color: red;"></td>
417+
<td style="text-align: center; color: green;"></td>
418418
<td style="text-align: center; color: green;">✔</td>
419419
<td style="text-align: center;">N/A</td>
420420
<td style="text-align: center;">N/A</td>
@@ -495,14 +495,14 @@
495495
<td style="text-align: center; color: green;">✔</td>
496496
<td style="text-align: center;">N/A</td>
497497
<td style="text-align: center; color: orange;">●</td>
498-
<td style="text-align: center; color: orange;">●</td>
498+
<td style="text-align: center; color: orange;">● <a href="#footnote7"><sup>7</sup></a></td>
499499
</tr>
500500
<tr>
501501
<td style="padding-left: 1em;">Number Format Mask</td>
502502
<td style="text-align: center; color: green;">✔</td>
503503
<td style="text-align: center; color: green;">✔</td>
504504
<td style="text-align: center; color: green;">✔</td>
505-
<td style="text-align: center; color: green;"></td>
505+
<td style="text-align: center; color: orange;"></td>
506506
<td style="text-align: center; color: green;">✔</td>
507507
<td style="text-align: center;">N/A</td>
508508
<td style="text-align: center; color: green;">✔</td>
@@ -517,7 +517,7 @@
517517
<td style="text-align: center; color: green;">✔</td>
518518
<td style="text-align: center;">N/A</td>
519519
<td style="text-align: center; color: red;">✖</td>
520-
<td style="text-align: center; color: orange;">●</td>
520+
<td style="text-align: center; color: orange;">● <a href="#footnote7"><sup>7</sup></a></td>
521521
</tr>
522522
<tr>
523523
<td style="padding-left: 2em;">Horizontal</td>
@@ -583,7 +583,7 @@
583583
<td style="text-align: center; color: green;">✔</td>
584584
<td style="text-align: center;">N/A</td>
585585
<td style="text-align: center; color: green;">✔</td>
586-
<td style="text-align: center; color: green;"></td>
586+
<td style="text-align: center; color: orange;">● <a href="#footnote7"><sup>7</sup></a></td>
587587
</tr>
588588
<tr>
589589
<td style="padding-left: 2em;">Patterned</td>
@@ -605,7 +605,7 @@
605605
<td style="text-align: center; color: green;">✔</td>
606606
<td style="text-align: center;">N/A</td>
607607
<td style="text-align: center; color: green;">✔</td>
608-
<td style="text-align: center; color: green;"></td>
608+
<td style="text-align: center; color: orange;">● <a href="#footnote7"><sup>7</sup></a></td>
609609
</tr>
610610
<tr>
611611
<td style="padding-left: 2em;">Font Face</td>
@@ -704,7 +704,7 @@
704704
<td style="text-align: center; color: green;">✔</td>
705705
<td style="text-align: center;">N/A</td>
706706
<td style="text-align: center; color: orange;">●</td>
707-
<td style="text-align: center; color: green;"></td>
707+
<td style="text-align: center; color: orange;">● <a href="#footnote7"><sup>7</sup></a></td>
708708
</tr>
709709
<tr>
710710
<td style="padding-left: 2em;">Line Style</td>
@@ -797,13 +797,13 @@
797797
<tr>
798798
<td style="padding-left: 2em;">Alignment</td>
799799
<td style="text-align: center; color: red;">✖ <a href="#footnote3"><sup>3</sup></a></td>
800-
<td style="text-align: center; color: red;"></td>
800+
<td style="text-align: center; color: green;"></td>
801801
<td style="text-align: center; color: red;">✖</td>
802802
<td style="text-align: center; color: red;">✖</td>
803803
<td style="text-align: center; color: red;">✖</td>
804804
<td style="text-align: center;">N/A</td>
805805
<td style="text-align: center; color: red;">✖</td>
806-
<td style="text-align: center; color: red;"></td>
806+
<td style="text-align: center; color: green;"></td>
807807
</tr>
808808
<tr>
809809
<td style="padding-left: 2em;">Background Image</td>
@@ -929,7 +929,7 @@
929929
<tr>
930930
<td style="padding-left: 0.5em;"><a href="#setGetMacro"><strong>Macros</strong></a></td>
931931
<td style="text-align: center; color: red;">✖</td>
932-
<td style="text-align: center; color: green;"></td>
932+
<td style="text-align: center; color: orange;">● <a href="#footnote5"><sup>5</sup</td>
933933
<td style="text-align: center; color: red;">✖</td>
934934
<td style="text-align: center; color: red;">✖</td>
935935
<td style="text-align: center; color: red;">✖</td>
@@ -940,7 +940,7 @@
940940
<tr>
941941
<td style="padding-left: 0.5em;"><strong>Form Controls</strong></td>
942942
<td style="text-align: center; color: red;">✖</td>
943-
<td style="text-align: center; color: red;"></td>
943+
<td style="text-align: center; color: orange;">● <a href="#footnote4"><sup>4</sup</td>
944944
<td style="text-align: center; color: red;">✖</td>
945945
<td style="text-align: center; color: red;">✖</td>
946946
<td style="text-align: center; color: red;">✖</td>
@@ -1001,6 +1001,10 @@
10011001
1. <span id="footnote1">Only text contents</span>
10021002
2. <span id="footnote2">Only BIFF8 files support Rich Text. Prior to that, comments could only be plain text</span>
10031003
3. <span id="footnote3">Only BIFF8 files support alignment and rotation. Prior to that, comments could only be unformatted text</span>
1004+
4. <span id="footnote4">Xlsx forms and controls can be read and written but not otherwise manipulated</span>
1005+
5. <span id="footnote5">Xlsx macros can be read and written; their values can be retrieved and changed, but only in a binary form which is unlikely to be useful</span>
1006+
6. <span id="footnote6">There is very limited support for reading styles from an Ods spreadsheet. Writing styles has better support, although Number Format is incomplete.</span>
1007+
7. <span id="footnote7">In most cases, Html reader processes only inline styles; styles provided by Css classes may be ignored.</span>
10041008

10051009
## Writers
10061010

@@ -1184,7 +1188,7 @@
11841188
<td style="padding-left: 1em;">Row Height/Column Width</td>
11851189
<td style="text-align: center; color: green;">✔</td>
11861190
<td style="text-align: center; color: green;">✔</td>
1187-
<td style="text-align: center; color: red;"></td>
1191+
<td style="text-align: center; color: green;"></td>
11881192
<td style="text-align: center;">N/A</td>
11891193
<td style="text-align: center; color: green;">✔</td>
11901194
<td style="text-align: center; color: green;">✔</td>
@@ -1256,7 +1260,7 @@
12561260
<td style="padding-left: 1em;">Number Format Mask</td>
12571261
<td style="text-align: center; color: green;">✔</td>
12581262
<td style="text-align: center; color: green;">✔</td>
1259-
<td style="text-align: center; color: green;"></td>
1263+
<td style="text-align: center; color: orange;"></td>
12601264
<td style="text-align: center;">N/A</td>
12611265
<td style="text-align: center; color: green;">✔</td>
12621266
<td style="text-align: center; color: green;">✔</td>
@@ -1472,10 +1476,10 @@
14721476
<td style="padding-left: 0.5em;"><strong>Merged Cells</strong></td>
14731477
<td style="text-align: center; color: green;">✔</td>
14741478
<td style="text-align: center; color: green;">✔</td>
1475-
<td style="text-align: center; color: red;"></td>
1479+
<td style="text-align: center; color: green;"></td>
14761480
<td style="text-align: center;">N/A</td>
14771481
<td style="text-align: center; color: green;">✔</td>
1478-
<td style="text-align: center; color: red;"></td>
1482+
<td style="text-align: center; color: green;"></td>
14791483
</tr>
14801484
<tr>
14811485
<td style="padding-left: 0.5em;"><a href="#setGetComment"><strong>Cell Comments</strong></a></td>
@@ -1498,10 +1502,10 @@
14981502
<tr>
14991503
<td style="padding-left: 1em;">Alignment</td>
15001504
<td style="text-align: center; color: red;">✖</td>
1501-
<td style="text-align: center; color: red;"></td>
1505+
<td style="text-align: center; color: green;"></td>
15021506
<td style="text-align: center; color: red;">✖</td>
15031507
<td style="text-align: center;">N/A</td>
1504-
<td style="text-align: center; color: red;"></td>
1508+
<td style="text-align: center; color: green;"></td>
15051509
<td style="text-align: center;">N/A</td>
15061510
</tr>
15071511
<tr>
@@ -1606,7 +1610,7 @@
16061610
<tr>
16071611
<td style="padding-left: 0.5em;"><a href="#setGetMacro"><strong>Macros</strong></a></td>
16081612
<td style="text-align: center; color: red;">✖</td>
1609-
<td style="text-align: center; color: green;"></td>
1613+
<td style="text-align: center; color: orange;">● <a href="#footnote5"><sup>5</sup</td>
16101614
<td style="text-align: center; color: red;">✖</td>
16111615
<td style="text-align: center;">N/A</td>
16121616
<td style="text-align: center; color: red;">✖</td>
@@ -1615,7 +1619,7 @@
16151619
<tr>
16161620
<td style="padding-left: 0.5em;"><strong>Form Controls</strong></td>
16171621
<td style="text-align: center; color: red;">✖</td>
1618-
<td style="text-align: center; color: red;"></td>
1622+
<td style="text-align: center; color: orange;">● <a href="#footnote4"><sup>4</sup</td>
16191623
<td style="text-align: center; color: red;">✖</td>
16201624
<td style="text-align: center;">N/A</td>
16211625
<td style="text-align: center; color: red;">✖</td>
@@ -1803,8 +1807,8 @@
18031807
</tr>
18041808
<tr>
18051809
<td id="setGetMacro"><strong>Macros</strong></td>
1806-
<td>$spreadsheet->getMacrosCode();</td>
1807-
<td>$spreadsheet->setMacrosCode();</td>
1810+
<td>$spreadsheet->getMacrosCode();<a href="#footnote5"><sup>5</sup></td>
1811+
<td>$spreadsheet->setMacrosCode();<a href="#footnote5"><sup>5</sup></td>
18081812
</tr>
18091813
<tr>
18101814
<td id="setGetSecurity"><strong>Security</strong></td>

src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum
8181
}
8282

8383
$rowNum = $rowNum ?? 0;
84-
$originalColumnNum = $columnNum;
8584
$columnNum = $columnNum ?? 0;
8685

8786
try {
@@ -91,6 +90,17 @@ public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum
9190
return $e->getMessage();
9291
}
9392

93+
if (is_array($matrix) && count($matrix) === 1 && $rowNum > 1) {
94+
$matrixKey = array_keys($matrix)[0];
95+
if (is_array($matrix[$matrixKey])) {
96+
$tempMatrix = [];
97+
foreach ($matrix[$matrixKey] as $key => $value) {
98+
$tempMatrix[$key] = [$value];
99+
}
100+
$matrix = $tempMatrix;
101+
}
102+
}
103+
94104
if (!is_array($matrix) || ($rowNum > count($matrix))) {
95105
return ExcelError::REF();
96106
}
@@ -101,9 +111,6 @@ public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum
101111
if ($columnNum > count($columnKeys)) {
102112
return ExcelError::REF();
103113
}
104-
if ($originalColumnNum === null && 1 < count($columnKeys)) {
105-
return ExcelError::REF();
106-
}
107114

108115
if ($columnNum === 0) {
109116
return self::extractRowValue($matrix, $rowKeys, $rowNum);

src/PhpSpreadsheet/Reader/Ods.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use DOMDocument;
77
use DOMElement;
88
use DOMNode;
9+
use DOMText;
910
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
1011
use PhpOffice\PhpSpreadsheet\Cell\DataType;
1112
use PhpOffice\PhpSpreadsheet\Helper\Dimension as HelperDimension;
@@ -403,8 +404,11 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp
403404
}
404405

405406
$columnID = 'A';
406-
/** @var DOMElement $cellData */
407+
/** @var DOMElement|DOMText $cellData */
407408
foreach ($childNode->childNodes as $cellData) {
409+
if ($cellData instanceof DOMText) {
410+
continue; // should just be whitespace
411+
}
408412
if ($this->getReadFilter() !== null) {
409413
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
410414
if ($cellData->hasAttributeNS($tableNs, 'number-columns-repeated')) {
@@ -519,7 +523,7 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp
519523
break;
520524
case 'boolean':
521525
$type = DataType::TYPE_BOOL;
522-
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
526+
$dataValue = ($cellData->getAttributeNS($officeNs, 'boolean-value') === 'true') ? true : false;
523527

524528
break;
525529
case 'percentage':

src/PhpSpreadsheet/Writer/Html.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,11 @@ public function generateHTMLHeader(bool $includeStyles = false): string
356356
$html .= ' <head>' . PHP_EOL;
357357
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . PHP_EOL;
358358
$html .= ' <meta name="generator" content="PhpSpreadsheet, https://github.com/PHPOffice/PhpSpreadsheet" />' . PHP_EOL;
359-
$html .= ' <title>' . htmlspecialchars($properties->getTitle(), Settings::htmlEntityFlags()) . '</title>' . PHP_EOL;
359+
$title = $properties->getTitle();
360+
if ($title === '') {
361+
$title = $this->spreadsheet->getActiveSheet()->getTitle();
362+
}
363+
$html .= ' <title>' . htmlspecialchars($title, Settings::htmlEntityFlags()) . '</title>' . PHP_EOL;
360364
$html .= self::generateMeta($properties->getCreator(), 'author');
361365
$html .= self::generateMeta($properties->getTitle(), 'title');
362366
$html .= self::generateMeta($properties->getDescription(), 'description');
@@ -1463,11 +1467,21 @@ private function generateRowWriteCell(
14631467
$xcssClass['height'] = $height;
14641468
}
14651469
//** end of redundant code **
1470+
if ($this->useInlineCss) {
1471+
foreach (['border-top', 'border-bottom', 'border-right', 'border-left'] as $borderType) {
1472+
if (($xcssClass[$borderType] ?? '') === 'none #000000') {
1473+
unset($xcssClass[$borderType]);
1474+
}
1475+
}
1476+
}
14661477

14671478
if ($htmlx) {
14681479
$xcssClass['position'] = 'relative';
14691480
}
14701481
$html .= ' style="' . $this->assembleCSS($xcssClass) . '"';
1482+
if ($this->useInlineCss) {
1483+
$html .= ' class="gridlines gridlinesp"';
1484+
}
14711485
}
14721486
$html = $this->generateRowSpans($html, $rowSpan, $colSpan);
14731487

src/PhpSpreadsheet/Writer/Ods/Content.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
44

5+
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
56
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException;
67
use PhpOffice\PhpSpreadsheet\Cell\Cell;
78
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
@@ -211,8 +212,8 @@ private function writeCells(XMLWriter $objWriter, RowCellIterator $cells): void
211212
switch ($cell->getDataType()) {
212213
case DataType::TYPE_BOOL:
213214
$objWriter->writeAttribute('office:value-type', 'boolean');
214-
$objWriter->writeAttribute('office:value', $cell->getValueString());
215-
$objWriter->writeElement('text:p', $cell->getValueString());
215+
$objWriter->writeAttribute('office:boolean-value', $cell->getValue() ? 'true' : 'false');
216+
$objWriter->writeElement('text:p', Calculation::getInstance()->getLocaleBoolean($cell->getValue() ? 'TRUE' : 'FALSE'));
216217

217218
break;
218219
case DataType::TYPE_ERROR:

src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksh
16021602

16031603
break;
16041604
case 's': // String
1605-
$this->writeCellString($objWriter, $mappedType, $cellValueString, $flippedStringTable);
1605+
$this->writeCellString($objWriter, $mappedType, ($cellValue instanceof RichText) ? $cellValue : $cellValueString, $flippedStringTable);
16061606

16071607
break;
16081608
case 'f': // Formula

tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,15 @@ class CalculationFunctionListTest extends TestCase
1313
{
1414
private string $compatibilityMode;
1515

16-
private string $locale;
17-
1816
protected function setUp(): void
1917
{
2018
$this->compatibilityMode = Functions::getCompatibilityMode();
21-
$calculation = Calculation::getInstance();
22-
$this->locale = $calculation->getLocale();
2319
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
2420
}
2521

2622
protected function tearDown(): void
2723
{
2824
Functions::setCompatibilityMode($this->compatibilityMode);
29-
$calculation = Calculation::getInstance();
30-
$calculation->setLocale($this->locale);
3125
}
3226

3327
/**

0 commit comments

Comments
 (0)