Formula in ColumnHeader

Posted by: sameek on 8 September 2017, 12:37 pm EST

  • Posted 8 September 2017, 12:37 pm EST

    Are you able to put a formula in a columnheader.  I am not able to get this to work?


    Thanks

  • Replied 8 September 2017, 12:37 pm EST

    Has this changed? It's been 9yrs, hopefully you provide something now :)
  • Replied 8 September 2017, 12:37 pm EST

    Hello,

    I'm pretty sure that should work, but I'm trying it out in code and its not correctly setting the formula in the column header. I have submitted this to the developers to look into, and I will get back to you.

    Regards,
    Kevin
  • Replied 8 September 2017, 12:37 pm EST

    Thanks Kevin! We'll be looking forward to your reply.
  • Replied 8 September 2017, 12:37 pm EST

    I noticed this is a .NET forum...we are developing in javascript and using:

    sheet.setFormula(2, i, formula, GC.Spread.Sheets.SheetArea.colHeader
  • Replied 8 September 2017, 12:37 pm EST

    Hello,


    This is not supported.

  • Replied 8 September 2017, 12:37 pm EST

    While we don't support formulas in column header cells, you could put the formulas in the first row and make it a frozen (fixed) row and then hide the column header row, making the first row appear as if it is the header.
  • Marked as Answer

    Replied 8 September 2017, 12:37 pm EST

    Hello,

    The way that Spread WinForms V10 is currently implemented, we only support the formula working internally in column headers, and not being able to refer to the sheet data area. However, you can make it work using some hidden API. Keep in mind that this will not be supported after V11. In the meantime, you can using something like the following code:

    FarPoint.Win.Spread.ColumnHeader ch;
    ch = fpSpread1.ActiveSheet.ColumnHeader;
    ch.RowCount = 2;
    fpSpread1.ActiveSheet.ColumnHeader.Cells[0, 0].Value = 2;
    fpSpread1.ActiveSheet.ColumnHeader.Cells[0, 1].Value = 3;
    ((DefaultSheetDataModel)fpSpread1.ActiveSheet.Models.ColumnHeaderData).SetFormula(1, 0, "SUM(A1:B1)");// Notice: A1:B1 belongs to the column header

    // This API is marked as internal, it is not meant for public use
    ((DefaultSheetDataModel)fpSpread1.ActiveSheet.Models.Data).ShareCalculations(fpSpread1.ActiveSheet.Models.ColumnHeaderData as DefaultSheetDataModel);
    ((DefaultSheetDataModel)fpSpread1.ActiveSheet.Models.ColumnHeaderData).SetFormula(1, 1, "SUM(Sheet1!A1:A5)");

    fpSpread1.ActiveSheet.Cells[0, 0].Value = 1;
    fpSpread1.ActiveSheet.Cells[1, 0].Value = 3;

    The developers are going to work on integrating that behavior into ColumnFooters. If it is successful, they can look into using it for other areas like ColumnHeaders and RowHeaders.

    In reference to your JS question, looks like you already have a response in that respective forum:

    http://sphelp.grapecity.com/forums/topic/having-formulas-setformula-applied-to-a-cell-in-the-header/

    Regards,
    Kevin
Need extra support?

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

Learn More

Forum Channels