Blank space in sheet name calculation error

Posted by: khauam.cardoso on 15 July 2025, 7:33 am EST

  • Posted 15 July 2025, 7:33 am EST

    Hello, I’m trying to use calculate to recalculate cells individually in my spread, but when the sheet name has a blank space in the name like ("Sheet1 "), the calculation ends up generating an error, how can I get around this?

    Angular 16

    spread 18.0.7

     const cellReference = GC.Spread.Sheets.CalcEngine.rangeToFormula(new GC.Spread.Sheets.Range(line, column, 1, 1));
        this.workbook.calculate(GC.Spread.Sheets.CalculationType.rebuild, `${sheet.name()}!${cellReference}`);

    error:

    ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading ‘c3n’)

    TypeError: Cannot read properties of undefined (reading ‘c3n’)

    at e.calculate (gc.spread.sheets.all.min.js:1068:1269771)

  • Posted 16 July 2025, 12:05 am EST - Updated 16 July 2025, 12:11 am EST

    Hi,

    We can reproduce the issue you mentioned on our end. This behavior occurs because when a sheet name contains spaces, it must be enclosed within single quotes; otherwise, the calculation will fail. This is consistent with how Microsoft Excel handles sheet names with spaces. Excel also requires single quotes around such sheet names in formula references.

    Please refer to the updated code snippet below, which correctly calculates the desired cell range without errors:

    const cellReference = GC.Spread.Sheets.CalcEngine.rangeToFormula(new GC.Spread.Sheets.Range(line, column, 1, 1));
    this.workbook.calculate(GC.Spread.Sheets.CalculationType.rebuild, `'${sheet.name()}'!${cellReference}`);

    You can further refer to the attached sample and the demonstration video that uses the above code snippet and calculates the workbook (see below).

    Please feel free to reach out if you encounter any further issues.

    Attachment: https://jscodemine.mescius.io/share/K368mL775EWGiHqlNuym5w/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fapp.js"%2C"%2Fstyles.css"]%2C"ActiveFile"%3A"%2Fapp.js"}

    Working:

    Best Regards,

    Chirag Gupta

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels