sc/inc/global.hxx               |    2 ++
 sc/source/core/data/dpcache.cxx |    7 ++++++-
 sc/source/core/data/global.cxx  |   17 +++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit fb138143df479e2f742ed194fdeb55606e032c77
Author:     Karthik Godha <[email protected]>
AuthorDate: Mon Feb 2 10:25:43 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 4 19:18:20 2026 +0100

    XLSX: Use Excel compatible errors in PivotTable
    
    Excel doesn't support all LO internal errors, replace them with Excel
    compatible errors
    Ex: #ADDIN?
    
    bug-document: forum-mso-en3-16864.xls
    Change-Id: Id6d4f9e2d36e16f859c08a9bf2a0f96fea87d3b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198509
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index e37b2dbaef58..6e986267c8a6 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -627,6 +627,8 @@ public:
                                             const SfxItemSet& rOldAttrs,
                                             const sal_uInt16      nWhich );
 
+    static bool IsValidOOXMLError(FormulaError nErrNumber);
+
     static ScUnitConverter* GetUnitConverter();
 
     /// strchr() functionality on unicode, as long as we need it for 
FormulaToken etc.
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 969bd5c01c4f..5819c0a8d566 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -149,7 +149,12 @@ void initFromCell(
 
     if (rCell.hasError())
     {
-        rData.SetErrorStringInterned(internString(rStrPool, 
rDoc.GetString(rPos.Col(), rPos.Row(), rPos.Tab())));
+        if (ScGlobal::IsValidOOXMLError(rCell.getFormula()->GetErrCode()))
+            rData.SetErrorStringInterned(
+                internString(rStrPool, rDoc.GetString(rPos.Col(), rPos.Row(), 
rPos.Tab())));
+        else
+            rData.SetErrorStringInterned(
+                internString(rStrPool, 
ScGlobal::GetErrorString(FormulaError::NotAvailable)));
     }
     else if (rCell.hasNumeric())
     {
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 50017bd40553..56f19267f47f 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -444,6 +444,23 @@ OUString ScGlobal::GetLongErrorString(FormulaError nErr)
     return ScResId(pErrNumber);
 }
 
+bool ScGlobal::IsValidOOXMLError(FormulaError nErrNumber)
+{
+    switch (nErrNumber)
+    {
+        case FormulaError::DivisionByZero:
+        case FormulaError::NotAvailable:
+        case FormulaError::NoName:
+        case FormulaError::NoCode:
+        case FormulaError::IllegalFPOperation:
+        case FormulaError::NoRef:
+        case FormulaError::NoValue:
+            return true;
+        default:
+            return false;
+    }
+}
+
 SvxBrushItem* ScGlobal::GetButtonBrushItem()
 {
     assert(!bThreadedGroupCalcInProgress);

Reply via email to