How to disable the column header name from setDataSource

Posted by: davide.vago on 28 August 2019, 10:44 pm EST

  • Posted 28 August 2019, 10:44 pm EST

    Good morning/evening

    Given a data structure passed via setDataSource (ref. http://help.grapecity.com/spread/SpreadSheets11/webframe.html#SpreadJS~GC.Spread.Sheets.Worksheet~setDataSource.html)

    I would like to remove the auto generation of the column name and keep the default A, B, C ... as I would like to have a good reference whenever a formula is applied/inspected

    I created a dataSource array with the first object the list of the column headers and frozen the first generated row to have the name reference but I really need to default the spreadsheet column titles to A,B,C

    Any idea on how to do that?

  • Marked as Answer

    Replied 29 August 2019, 7:13 pm EST

    Hi Davide,

    You may use the setValue() method to set the headers back to letters. Please refer to the following code snippet and the sample demonstrating the same:
    sheet.setValue(0, colIndex, colLetter, GC.Spread.Sheets.SheetArea.colHeader);

    https://codesandbox.io/s/spread-js-starter-rw46p

    Regards
  • Replied 29 August 2019, 8:15 pm EST

    Good morning/evening

    Thanks for the reply, I've tried to replicate your example from codesandbox and I get an error evaluating the formula.

    Logging:

    GC.Spread.Sheets.CalcEngine.evaluateFormula(
    window.spread.activeSheet,
    '=SUBSTITUTE(ADDRESS(1,' + colIndex + ',4),"0","")',
    0,
    0,
    ),


    returns an error: {_error: "#NAME?", _code: 29} so the column header gets populated by #NAME?
  • Replied 29 August 2019, 8:39 pm EST

    Apologies, I found the error I was making, I basically removed the sheet argument from your snippets as I'm referring to the window object.

    This solved my problem, thanks so much
Need extra support?

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

Learn More

Forum Channels