sc/qa/unit/data/xls/array_formula_with_macros.xls |binary sc/qa/unit/data/xls/formula_with_macros.xls |binary sc/qa/unit/subsequent_export_test4.cxx | 17 +++++++++++++++++ sc/source/filter/excel/xetable.cxx | 5 ++++- 4 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit f20b05d40f628b00f2990d3dd895f3bb23d0ae17 Author: Karthik Godha <[email protected]> AuthorDate: Tue Feb 17 17:42:29 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Wed Feb 18 21:38:23 2026 +0100 XLSX: Properly handle macros in array formulas This is a regression from 108f4aa94b98ca6deffdc169068c175605d5ba67, XML_f element of array formulas containing macros was not closed in XLSX export. Change-Id: Iffd482ec23797bc64647a07e991220f373986d95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199539 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/qa/unit/data/xls/array_formula_with_macros.xls b/sc/qa/unit/data/xls/array_formula_with_macros.xls new file mode 100644 index 000000000000..81ca74d793c7 Binary files /dev/null and b/sc/qa/unit/data/xls/array_formula_with_macros.xls differ diff --git a/sc/qa/unit/data/xls/formula_with_macros.xls b/sc/qa/unit/data/xls/formula_with_macros.xls new file mode 100644 index 000000000000..25e149d13312 Binary files /dev/null and b/sc/qa/unit/data/xls/formula_with_macros.xls differ diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 5af9933e5a5d..98749cd9a945 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -2470,6 +2470,23 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf170565_empty_functions) assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[6]/x:c[2]/x:f", u"PRODUCT(,)"); } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testMacrosInXLSX) +{ + // Array formula + createScDoc("xls/formula_with_macros.xls"); + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr); + CPPUNIT_ASSERT(pSheet); + assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[2]/x:c[1]/x:f", 0); + + // Regular formula + createScDoc("xls/array_formula_with_macros.xls"); + save(u"Calc Office Open XML"_ustr); + pSheet = parseExport(u"xl/worksheets/sheet1.xml"_ustr); + CPPUNIT_ASSERT(pSheet); + assertXPathContent(pSheet, "/x:worksheet/x:sheetData/x:row[2]/x:c[2]/x:f", u""); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 388939b73340..e9f9613b88f7 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1039,14 +1039,17 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->startElement(XML_f, XML_aca, ToPsz((mxTokArr && mxTokArr->IsVolatile()) || (mxAddRec && mxAddRec->IsVolatile()))); + bTagStarted = true; } rWorksheet->writeEscaped(XclXmlUtils::ToOUString( rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, &aTokenArray, mrScFmlaCell.GetErrCode())); - rWorksheet->endElement(XML_f); } } + if (bTagStarted) + rWorksheet->endElement(XML_f); + if( strcmp( sType, "inlineStr" ) == 0 ) { rWorksheet->startElement(XML_is);
