diff options
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 685a2cfe8689..eeb3d71c094d 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -325,6 +325,15 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken return nullptr; } + // Clamp the size of the matrix to rows which actually contain data. + // For e.g. SUM(IF over an entire column, this can make a big difference. + // Limit to ocEqual opcode for now, some opcodes behaviour differently if the + // input has empty space. + if (nTab1 == nTab2 && pCur->GetOpCode() == ocEqual) + { + pDok->ShrinkToDataArea(nTab1, nCol1, nRow1, nCol2, nRow2); + } + SCSIZE nMatCols = static_cast<SCSIZE>(nCol2 - nCol1 + 1); SCSIZE nMatRows = static_cast<SCSIZE>(nRow2 - nRow1 + 1); |