From 5f460e6ba731e5b9a803d1045afbe493ca13a637 Mon Sep 17 00:00:00 2001
From: oleibman <10341515+oleibman@users.noreply.github.com>
Date: Mon, 16 Feb 2026 01:19:26 -0800
Subject: [PATCH] Some Corrections
Sample 20_Read_Ods exposed some problems which are now corrected.
---
CHANGELOG.md | 1 +
samples/Basic2/20_Read_Ods.php | 2 +-
src/PhpSpreadsheet/Reader/Ods.php | 2 +-
src/PhpSpreadsheet/Writer/Ods/Content.php | 20 ++++++++++++++++++-
.../Reader/Ods/OdsTest.php | 3 +++
.../Writer/PreCalcTest.php | 5 ++++-
tests/data/Writer/Ods/content-with-data.xml | 2 +-
7 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57453a393..d4ef6593b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a
- Ods Reader column misalignment. [Issue #4802](https://github.com/PHPOffice/PhpSpreadsheet/issues/4802) [PR #4803](https://github.com/PHPOffice/PhpSpreadsheet/pull/4803)
- Image Css size in millimeters. [Issue #4800](https://github.com/PHPOffice/PhpSpreadsheet/issues/4800) [PR #4801](https://github.com/PHPOffice/PhpSpreadsheet/pull/4801)
- Ods improved handling of number formats. [Issue #3961](https://github.com/PHPOffice/PhpSpreadsheet/issues/3961) [Issue #4798](https://github.com/PHPOffice/PhpSpreadsheet/issues/4798) [PR #4806](https://github.com/PHPOffice/PhpSpreadsheet/pull/4806)
+- Ods Reader fonts and fills. [Issue #2622](https://github.com/PHPOffice/PhpSpreadsheet/issues/2622) [Issue #1191](https://github.com/PHPOffice/PhpSpreadsheet/issues/1191) [PR #4810](https://github.com/PHPOffice/PhpSpreadsheet/pull/4810)
## 2026-01-10 - 5.4.0
diff --git a/samples/Basic2/20_Read_Ods.php b/samples/Basic2/20_Read_Ods.php
index e9ec14f36..a4a4d4144 100644
--- a/samples/Basic2/20_Read_Ods.php
+++ b/samples/Basic2/20_Read_Ods.php
@@ -10,4 +10,4 @@ $spreadsheet = IOFactory::load($filename);
$helper->logRead('Ods', $filename, $callStartTime);
// Save
-$helper->write($spreadsheet, __FILE__);
+$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Ods']);
diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php
index cef1d120a..db27976a3 100644
--- a/src/PhpSpreadsheet/Reader/Ods.php
+++ b/src/PhpSpreadsheet/Reader/Ods.php
@@ -1328,7 +1328,7 @@ class Ods extends BaseReader
$fonts['underline'] = $temp;
}
$temp = $textProperty->getAttributeNs($styleNs, 'text-line-through-type');
- if ($temp !== '') {
+ if ($temp !== '' && $temp !== 'none') {
$fonts['strikethrough'] = true;
}
diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php
index 6364cb440..3eba063fd 100644
--- a/src/PhpSpreadsheet/Writer/Ods/Content.php
+++ b/src/PhpSpreadsheet/Writer/Ods/Content.php
@@ -225,9 +225,11 @@ class Content extends WriterPart
break;
case DataType::TYPE_FORMULA:
$formulaValue = $cell->getValueString();
+ $formulaValueCalc = $formulaValue;
if ($this->getParentWriter()->getPreCalculateFormulas()) {
try {
$formulaValue = $cell->getCalculatedValueString();
+ $formulaValueCalc = $cell->getCalculatedValue();
} catch (CalculationException $e) {
// don't do anything
}
@@ -249,12 +251,28 @@ class Content extends WriterPart
}
}
$objWriter->writeAttribute('table:formula', $this->formulaConvertor->convertFormula($cell->getValueString()));
+ if (is_bool($formulaValueCalc)) {
+ $objWriter->writeAttribute(
+ 'office:value-type',
+ 'boolean'
+ );
+ $objWriter->writeAttribute(
+ 'office:boolean-value',
+ $formulaValueCalc ? 'true' : 'false'
+ );
+ $objWriter->writeElement('text:p', $formulaValueCalc ? 'TRUE' : 'FALSE');
+
+ break;
+ }
if (!is_numeric($formulaValue)) {
$objWriter->writeAttribute(
'office:value-type',
'string'
);
- $objWriter->writeAttribute('office:value', $formulaValue);
+ $objWriter->writeAttribute(
+ 'office:string-value',
+ $formulaValue
+ );
$objWriter->writeElement('text:p', $formulaValue);
break;
diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php
index b13277465..df2548526 100644
--- a/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php
+++ b/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php
@@ -271,6 +271,9 @@ class OdsTest extends TestCase
self::assertEquals(Font::UNDERLINE_SINGLE, $style->getFont()->getUnderline());
$style = $firstSheet->getCell('A7')->getStyle();
self::assertEquals(Font::UNDERLINE_DOUBLE, $style->getFont()->getUnderline());
+ self::assertFalse($style->getFont()->getStrikethrough());
+ $style = $firstSheet->getStyle('A8');
+ self::assertTrue($style->getFont()->getStrikethrough());
$style = $firstSheet->getCell('E1')->getStyle();
self::assertTrue($style->getFont()->getBold());
diff --git a/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php b/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php
index 818070171..dfadeab1f 100644
--- a/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php
+++ b/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php
@@ -134,7 +134,10 @@ class PreCalcTest extends AbstractFunctional
$data = self::readFile($file);
// confirm that file contains B2 pre-calculated or not as appropriate
if ($preCalc === false) {
- self::assertStringContainsString('table:formula="of:=3+[.A3]" office:value-type="string" office:value="=3+A3"', $data);
+ self::assertStringContainsString(
+ 'table:formula="of:=3+[.A3]" office:value-type="string" office:string-value="=3+A3"',
+ $data
+ );
} else {
self::assertStringContainsString(' table:formula="of:=3+[.A3]" office:value-type="float" office:value="14"', $data);
}
diff --git a/tests/data/Writer/Ods/content-with-data.xml b/tests/data/Writer/Ods/content-with-data.xml
index 7912c05c6..3b10bb21e 100644
--- a/tests/data/Writer/Ods/content-with-data.xml
+++ b/tests/data/Writer/Ods/content-with-data.xml
@@ -100,7 +100,7 @@
FALSE
-
+
1 1