Number cell issue

Posted by: koustubh on 8 September 2017, 2:19 pm EST

  • Posted 8 September 2017, 2:19 pm EST


    Hello,


    I have defined celltype as numbercelltype and assign the following property to my number cell type.


    ncell.NegativeFormat = FarPoint.Win.Spread.CellType.NegativeFormat.Parentheses


    I am populating this cell with some database values with calcuation


    eg.


    spdata.sheet[0].cells[0,0].text = value1 + value2;


    Value1 and Value2 both are comming from database and both are negative numbers but it is display in cell as positive number without Parentheses.


    If I us the following code


    spdata.sheet[0].cells[0,0].text = value1 ; It is giving me correct out put with Parentheses.


    Why this happens.


    Koustubh More.

  • Replied 8 September 2017, 2:19 pm EST

    Hello,

    Please try using the Value property instead of Text to set the sum of the negative values in spread's cell. Here is the sample code for the same wherein, bound Column[1] in Spread have negative values coming from database and Cells[6,1] shows the sum of those negative values with parentheses:

                string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\Microsoft Office\\OFFICE11\\SAMPLES\\FirstDataBase.mdb";
                OleDbConnection con = new OleDbConnection(connectionString);
                string qstringCustomers = "SELECT * FROM CustomerTable";
                DataSet ds = new DataSet();
                OleDbDataAdapter adapterCustomers = new OleDbDataAdapter(qstringCustomers, con);
                adapterCustomers.Fill(ds, "CustomerTable");
                fpSpread1.DataSource = ds;

                FarPoint.Win.Spread.CellType.NumberCellType ncell = new FarPoint.Win.Spread.CellType.NumberCellType();
                ncell.NegativeFormat = FarPoint.Win.Spread.CellType.NegativeFormat.Parentheses;
                fpSpread1.ActiveSheet.Columns[1].CellType = ncell;
                int num = (int)fpSpread1.ActiveSheet.Cells[3, 1].Value;
                int num1 = (int)fpSpread1.ActiveSheet.Cells[2, 1].Value;
                fpSpread1.ActiveSheet.Cells[6, 1].Value = num + num1;

    Please have a look at the code and let us know your observations on the same. Thanks.

     

Need extra support?

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

Learn More

Forum Channels