How to set Cell Type in silverlight Spread.net

Posted by: kamalkishore on 10 September 2017, 1:57 am EST

  • Posted 10 September 2017, 1:57 am EST

    Hello,


    How to set CellType to Numeric in silverlight Spread.net..Want to calculating Avrage formula  eg.Average(A2:A5)


     


    Thanks,


     

  • Replied 10 September 2017, 1:57 am EST

    Hello,

    You may set the formatter to numeric for a cell and apply the formula. For example:

                gcSpreadSheet1.ActiveSheet.Cells[1, 2].Formatter = new GeneralFormatter(FormatMode.StandardNumericMode, "C3");
                gcSpreadSheet1.ActiveSheet.Cells[1, 2].Value = 1234.12;

     

    Thanks,

  • Replied 23 March 2021, 11:04 pm EST

    Hello,
    I applied the answer but I do not see the cell update according to the formula:
                GcSpreadSheet gcSpreadSheet1 = sender as GcSpreadSheet;
    gcSpreadSheet1.ActiveSheet.Cells[1, 2].Formatter = new GeneralFormatter(FormatMode.StandardNumericMode, "C3");
    gcSpreadSheet1.ActiveSheet.Cells[1, 2].Value = 1234.12;
    gcSpreadSheet1.ActiveSheet.Cells[1, 3].Formatter = new GeneralFormatter(FormatMode.StandardNumericMode, "C3");
    gcSpreadSheet1.ActiveSheet.Cells[1, 3].Formula = "=C2";


    Is there another step or setting to do before?
  • Replied 24 March 2021, 1:25 am EST

    I noted it works only after I edit the cells A1 or B1. But the behavior in Excel is not bound to this order. In Excel, I can set the number in cells A1 and B1 first and then set the formula in C1. After pressing Enter the cell containing the formula is update immediately.
    In code the formula should be set first, then the initial displaying is ok, but what when user wants to set values in cells first and THEN set the formula in another cell? It will not work as in Excel.
  • Replied 24 March 2021, 5:17 pm EST

    Hi Jose,
    You can call Recalculate() method of spreadsheet to calculate the formulas.

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
    GcSpreadSheet gcSpreadSheet1 = gcSpreadSheet as GcSpreadSheet;
    gcSpreadSheet1.ActiveSheet.Cells[1, 2].Formatter = new GeneralFormatter(FormatMode.StandardNumericMode, "C3");
    gcSpreadSheet1.ActiveSheet.Cells[1, 2].Value = 1234.12;
    gcSpreadSheet1.ActiveSheet.Cells[1, 3].Formatter = new GeneralFormatter(FormatMode.StandardNumericMode, "C3");
    gcSpreadSheet1.ActiveSheet.Name = "Sheet1";
    gcSpreadSheet1.ActiveSheet.Cells[1, 3].Formula = "C2";
    gcSpreadSheet1.ActiveSheet.Recalculate();
    gcSpreadSheet1.EditEnd += GcSpreadSheet1_EditEnd;

    }

    private void GcSpreadSheet1_EditEnd(object sender, EditCellEventArgs e)
    {
    gcSpreadSheet.ActiveSheet.Recalculate();
    }


    Hope, this will solve your issue.

    Thanks,
  • Replied 28 March 2021, 9:23 pm EST

    Hello,
    at my side, it is not working. Can I send you a sample app I created to demonstrate that? Better as email attachement.
  • Replied 29 March 2021, 8:00 pm EST

    Hi,
    Yes, this is better to share your application with us. So that we can assist you accordingly.
    You can post your query @ https://www.grapecity.com/my-account/my-support and then share your application.
    So that others cannot see your query/application.

    Thanks,
  • Replied 30 March 2021, 5:52 pm EST

    Hello, a Case with attached sample app was created. Thanks.
  • Replied 5 April 2021, 3:38 am EST

    HI,
    Your new case has been answered. Please check.

    Thanks
Need extra support?

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

Learn More

Forum Channels