Unplanned
Last Updated: 31 Aug 2026 14:59 by Mohd
Mohd
Created on: 31 Aug 2026 14:59
Category: Spreadsheet
Type: Bug Report
0
Spreadsheet returns incorrect dependent formula results when imported Excel formulas evaluate near zero

Bug report

    Steps to reproduce

    1. Open the Spreadsheet demo.
    2. Import TestExcel.xlsx.
    3. Compare the formula cell results with the same file opened in Microsoft Excel.

    Current behavior

    After import, some formula cells produce different results than Excel when the intermediate result is very close to zero.

    Observed example from the attached file:

    • In Excel:

      • E1 = 0
      • E2 = 0
      • F1 = 55110.305475240835
    • In Spreadsheet after import:

      • E1 = 0.00000000004366
      • E2 = 0.000000000043660000000000000000
      • F1 = 0

    Expected behavior

    Spreadsheet should match Excel results for the imported workbook, including cases where formulas evaluate to values extremely close to zero.

    Notes

    The issue appears related to formula recalculation after import and handling of floating-point precision near zero.

    In the attached file:

    • The imported numeric inputs are:

      • A1 = 79590.518373344006
      • B1 = 0.16372664029103301
      • C1 = 4
      • D1 = 82665.458212861093
    • The formula in E1 is:

      • A1*(1+B1)^(1/C1)-D1

    Excel stores the result as 0, but Spreadsheet recalculates it to a very small positive number, which then changes the dependent IF result in F1.

    Environment

    • Spreadsheet core demo: local reproduction confirmed
    • File used: TestExcel.xlsx

    Workaround

      <script>
        const CANCELLATION_EPSILON = Number.EPSILON * 4;
    
        function collapseCancellationError(result, left, right) {
            const scale = Math.max(Math.abs(left), Math.abs(right));
    
            if (!scale || result === 0) {
                return result;
            }
    
            return Math.abs(result) <= CANCELLATION_EPSILON * scale ? 0 : result;
        }
        const { defineFunction } = KendoSpreadsheetCommon;
        defineFunction('binary+', function(a, b) {
            return collapseCancellationError(a + b, a, b);
        }).args([
            ['*a', ['or', 'number', ['null', 0]]],
            ['*b', ['or', 'number', ['null', 0]]]
        ]);
    
        defineFunction('binary-', function(a, b) {
            return collapseCancellationError(a - b, a, b);
        }).args([
            ['*a', ['or', 'number', ['null', 0]]],
            ['*b', ['or', 'number', ['null', 0]]]
        ]);
      </script>

    TestExcel.xlsx

    0 comments