sc/source/filter/inc/formulabuffer.hxx | 4 ++++ sc/source/filter/oox/formulabuffer.cxx | 18 ++++++++++++++++++ sc/source/filter/oox/sheetdatabuffer.cxx | 3 +++ 3 files changed, 25 insertions(+)
New commits: commit a2305e02114c203bc58f4a174debd3bbb00a9d6b Author: Karthik Godha <[email protected]> AuthorDate: Fri Feb 6 21:28:53 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Tue Feb 10 12:18:58 2026 +0100 tdf#170677: DataTable is not properly imported When opening an XLSX file containing DataTable, values of the cells in the DataTable are missing. We have to manually reapply the formula to see the values. Change-Id: I1777a3aea2c82632575f1365fe1b7cdde9ae3bad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198939 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/source/filter/inc/formulabuffer.hxx b/sc/source/filter/inc/formulabuffer.hxx index 512b1feb3c81..11b088d6ac8f 100644 --- a/sc/source/filter/inc/formulabuffer.hxx +++ b/sc/source/filter/inc/formulabuffer.hxx @@ -92,6 +92,8 @@ private: SheetItem getSheetItem( SCTAB nTab ); + std::vector<ScRange> maDataTables; + public: explicit FormulaBuffer( const WorkbookHelper& rHelper ); void finalizeImport(); @@ -113,6 +115,8 @@ public: /// ensure sizes of vectors matches the number of sheets void SetSheetCount( SCTAB nSheets ); + + void addDataTable(const ScRange& rRange) { maDataTables.push_back(rRange); } }; } diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index 29a1c80b4fb6..8e6f7e01eb85 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -381,6 +381,22 @@ void processSheetFormulaCells( applyCellFormulaValues(rDoc, *rItem.mpCellFormulaValues, rWorkbookHelper); } +void processDataTables(ScDocumentImport& rDoc, const std::vector<ScRange>& rDataTables) +{ + for (const auto& rRange : rDataTables) + { + for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol) + { + for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow) + { + ScAddress aAddr(nCol, nRow, rRange.aStart.Tab()); + if (ScFormulaCell* pCell = rDoc.getDoc().GetFormulaCell(aAddr)) + pCell->SetDirty(); + } + } + } +} + } FormulaBuffer::SharedFormulaEntry::SharedFormulaEntry( @@ -433,6 +449,8 @@ void FormulaBuffer::finalizeImport() processSheetFormulaCells(rDoc, rItem, getExternalLinks().getLinkInfos(), *this); + processDataTables(rDoc, maDataTables); + // With formula results being set and not recalculated we need to // force-trigger adding all linked external files to the LinkManager. rDoc.getDoc().GetExternalRefManager()->addFilesToLinkManager(); diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index e9286d5f1523..2e42b1481a44 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -679,6 +679,7 @@ void SheetDataBuffer::finalizeTableOperation( const ScRange& rRange, const DataT aParam.aRefRowCell.Set(aRef1.Col(), aRef1.Row(), aRef1.Tab(), false, false, false); aParam.aRefColCell.Set(aRef2.Col(), aRef2.Row(), aRef2.Tab(), false, false, false); rDoc.setTableOpCells(aScRange, aParam); + getFormulaBuffer().addDataTable(aScRange); return; } @@ -694,6 +695,7 @@ void SheetDataBuffer::finalizeTableOperation( const ScRange& rRange, const DataT aParam.aRefFormulaEnd = aParam.aRefFormulaCell; aScRange.aStart.IncRow(-1); rDoc.setTableOpCells(aScRange, aParam); + getFormulaBuffer().addDataTable(aScRange); } else { @@ -704,6 +706,7 @@ void SheetDataBuffer::finalizeTableOperation( const ScRange& rRange, const DataT aParam.aRefFormulaEnd = aParam.aRefFormulaCell; aScRange.aStart.IncCol(-1); rDoc.setTableOpCells(aScRange, aParam); + getFormulaBuffer().addDataTable(aScRange); } }
