sc/qa/unit/data/xlsx/totalsRowShown.xlsx |binary
 sc/qa/unit/subsequent_export_test4.cxx   |   11 +++++++++++
 sc/source/filter/excel/xedbdata.cxx      |    5 +++--
 3 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit dc4a0d64b2d0baaea0299406dd9cc2cc7bcd1ec8
Author:     Balazs Varga <[email protected]>
AuthorDate: Mon Jan 5 08:43:10 2026 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 8 14:33:34 2026 +0100

    Table Style: ooxml export: fix corrupt ooxml files because
    
    of XML_totalsRowShown with value "0". We don't support totalsRowShown
    in core as it should be according to ooxml standard. totalsRowShown is
    false until we didn't set the Total row for the first time, after that
    it is always true.
    If there are totals or have any total row attribute is set, Total Row was 
shown.
    
    TODO: handle XML_totalsRowShown in core.
    
    regression after: e725c5b9327424fb927ed251d54b6913ae9d8568
    
    Change-Id: Id3233afa760c198401d5a9f4a9637e907dd5cd63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196532
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>

diff --git a/sc/qa/unit/data/xlsx/totalsRowShown.xlsx 
b/sc/qa/unit/data/xlsx/totalsRowShown.xlsx
new file mode 100644
index 000000000000..5503ae3a3784
Binary files /dev/null and b/sc/qa/unit/data/xlsx/totalsRowShown.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 2403bb9f2c18..9f78e4e38a14 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1793,6 +1793,17 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, 
testTotalsRowFunction)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testTotalsRowShown)
+{
+    createScDoc("xlsx/totalsRowShown.xlsx");
+    saveAndReload(u"Calc Office Open XML"_ustr);
+    {
+        xmlDocUniquePtr pDocXml = parseExport(u"xl/tables/table1.xml"_ustr);
+        CPPUNIT_ASSERT(pDocXml);
+        assertXPathNoAttribute(pDocXml, "/x:table", "totalsRowShown");
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf167689_xmlMaps_and_xmlColumnPr)
 {
     createScDoc("xlsx/tdf167689_xmlMaps_and_xmlColumnPr.xlsx");
diff --git a/sc/source/filter/excel/xedbdata.cxx 
b/sc/source/filter/excel/xedbdata.cxx
index fad30749c746..522b5ea19747 100644
--- a/sc/source/filter/excel/xedbdata.cxx
+++ b/sc/source/filter/excel/xedbdata.cxx
@@ -193,7 +193,7 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, 
const Entry& rEntry )
         = rData.GetTotalRowAttributes(formula::FormulaGrammar::GRAM_OOXML);
 
     // if the Total row have ever been showed it will be true
-    bool hasAnySetValue = std::any_of(aTotalValues.begin(), aTotalValues.end(),
+    bool hasAnySetValue = rData.HasTotals() || 
std::any_of(aTotalValues.begin(), aTotalValues.end(),
                                       [](const TableColumnAttributes& attr)
                                       {
                                           return 
attr.maTotalsRowLabel.has_value()
@@ -210,7 +210,8 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, 
const Entry& rEntry )
         XML_tableType, tableType,
         XML_headerRowCount, ToPsz10(rData.HasHeader()),
         XML_totalsRowCount, ToPsz10(rData.HasTotals()),
-        XML_totalsRowShown, ToPsz10(hasAnySetValue)
+        XML_totalsRowShown, (hasAnySetValue ? nullptr : ToPsz10(false)) // we 
don't support that but
+        // if there are totals or any total row attribute is set they are shown
         // OOXTODO: XML_comment, ...,
         // OOXTODO: XML_connectionId, ...,
         // OOXTODO: XML_dataCellStyle, ...,

Reply via email to