sc/source/filter/inc/xcl97rec.hxx | 2 ++ sc/source/filter/xcl97/xcl97rec.cxx | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
New commits: commit 9fd010d8423f01c0a33b40746be6189e4d5034d9 Author: Karthik Godha <[email protected]> AuthorDate: Sun Jan 18 14:23:03 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Mon Jan 19 13:20:12 2026 +0100 sc: XLSX - Skip writing empty scenarios In XLSX export, scenarios must contain at least one valid scenario element. bug-document: forum-fr-42975.xls Change-Id: I543a5637971d71de1d9d55f6e81a23d946495b6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197534 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 57210208ddad..27a7b4261af5 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -399,6 +399,8 @@ public: virtual std::size_t GetLen() const override; virtual void SaveXml( XclExpXmlStream& rStrm ) override; + + const std::vector<ExcEScenarioCell>& GetCells() { return aCells; } }; class ExcEScenarioManager : public ExcRecord diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index e8518fc540ff..94a25cd60ad2 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1656,7 +1656,17 @@ void ExcEScenarioManager::Save( XclExpStream& rStrm ) void ExcEScenarioManager::SaveXml( XclExpXmlStream& rStrm ) { - if( aScenes.empty() ) + bool bValidScenarios = false; + for (ExcEScenario& rScenario : aScenes) + { + if (rScenario.GetCells().size()) + { + bValidScenarios = true; + break; + } + } + + if (!bValidScenarios) return; sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream(); @@ -1666,8 +1676,11 @@ void ExcEScenarioManager::SaveXml( XclExpXmlStream& rStrm ) // OOXTODO: XML_sqref ); - for( ExcEScenario& rScenario : aScenes ) - rScenario.SaveXml( rStrm ); + for (ExcEScenario& rScenario : aScenes) + { + if (rScenario.GetCells().size()) + rScenario.SaveXml(rStrm); + } rWorkbook->endElement( XML_scenarios ); }
