Number cell issue

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

  • Posted 8 September 2017, 2:19 pm EST

    <FONT size=2>

    Hello,


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


    ncell.NegativeFormat = FarPoint.Win.Spread.CellType.</FONT><FONT color=#008080 size=2>NegativeFormat</FONT><FONT size=2>.Parentheses</FONT>


    <FONT size=2>I am populating this cell with some database values with calcuation </FONT>


    <FONT size=2>eg.</FONT>


    <FONT size=2>spdata.sheet[0].cells[0,0].text = value1 + value2;</FONT>


    <FONT size=2>Value1 and Value2 both are comming from database and both are negative numbers but it is display in cell as positive number without Parentheses.</FONT>


    <FONT size=2>If I us the following code </FONT>


    <FONT size=2>spdata.sheet[0].cells[0,0].text = value1 ; It is giving me correct out put with Parentheses.</FONT>


    <FONT size=2>Why this happens.</FONT>


    <FONT size=2>Koustubh More.

    </FONT>
  • 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:

    <blockquote>

                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;

    </blockquote>

    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