sc/source/filter/inc/xcl97rec.hxx | 2 ++ sc/source/filter/xcl97/xcl97rec.cxx | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
New commits: commit 2fb6a058287662a2afe5fa92cc3f768749c5e850 Author: Karthik Godha <[email protected]> AuthorDate: Sun Jan 18 14:23:03 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Wed Jan 28 14:01:09 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]> (cherry picked from commit 9fd010d8423f01c0a33b40746be6189e4d5034d9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198263 Tested-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 8e6fcb633898..41ca84b40f7b 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1653,7 +1653,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(); @@ -1663,8 +1673,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 ); }
