First column of data is blank

Posted by: baker-tony on 8 September 2017, 1:55 pm EST

  • Posted 8 September 2017, 1:55 pm EST

    <FONT size=3 face=Calibri>Hi, I’m trailing your spread software.</FONT>


    <o:p><FONT size=3 face=Calibri> </FONT></o:p>


    <FONT size=3 face=Calibri>First thing I did was try to bind to a DataTable (which a datagrid displays correctly). The first column of data didn’t display.</FONT>


    <o:p><FONT size=3 face=Calibri> </FONT></o:p>


    <FONT size=3 face=Calibri>A dataGrid displays the data perfectly.</FONT>


    <o:p><FONT size=3 face=Calibri> </FONT></o:p>


    <FONT size=3 face=Calibri>The first column is of type “Int32”, second columnd is of type “Int16” and the other 4 data columns are of type “single”. Here’s the code I use to bind to the two sheets:</FONT>


    <FONT size=3 face=Calibri>                DataTable data = MyMethod("myTable");</FONT>


    <FONT size=3 face=Calibri>fpSpread1.Sheets[0].DataSource = data;</FONT>


    <FONT size=3 face=Calibri>dataGridView1.DataSource = data;</FONT>


    <o:p><FONT size=3 face=Calibri> </FONT></o:p>


    <FONT size=3><FONT face=Calibri>same result if I go <I>fpSpread1.DataSource = data;</I></FONT></FONT>


    <o:p><FONT size=3 face=Calibri> </FONT></o:p>


    <FONT size=3 face=Calibri>What’s going on?</FONT>

  • Replied 8 September 2017, 1:55 pm EST

    Actually, I've also just tried this code:


                DataTable data = new DataTable("tableName");
                data.Columns.Add("date", System.Type.GetType("System.Int32"));
                DataRow row = data.NewRow();
                row[0] = "20090101";
                data.Rows.Add(row);
                fpSpread1.DataSource = data;
                dataGridView1.DataSource = data;


    I get the same problem! The value "20090101" should display in a one cell spread. Does for the DataGrid, but not for FpSpread!

  • Replied 8 September 2017, 1:55 pm EST

    Hello Baker, 

    FpSpread identifies the datatype of the data in the cell and automatically assigns the CellType to the column. In your example code, you are setting the Type of the column to System.Int32, due to which the FpSpread automatically assigns the CellType of the column to NumberCellType. The default MaxValue of NumberCellType is 9999999.99, due to which <span class="Apple-style-span" style="font-family:Tahoma;">20090101 value is ignored by the spread. </span>

    To resolve this, you may either disable the automatic celltype before setting the datasource by setting the

    fpSpread1.ActiveSheet.DataAutoCellTypes = false;

    Or, you may increase the MaxValue of the NumberCellType after seting the datasource of the spread using: 

                FarPoint.Win.Spread.CellType.NumberCellType NCT = fpSpread1.ActiveSheet.Columns[0].CellType as FarPoint.Win.Spread.CellType.NumberCellType;

                NCT.MaximumValue = 30000000;

    Regards, 

     

  • Replied 8 September 2017, 1:55 pm EST

    Thanks for ya quick response! The line:


    fpSpread1.ActiveSheet.DataAutoCellTypes = false;


    worked. I guess it would've been nice to have something like "#####" in the cell if it was out of range or something.


    Cheers,


    Tony.

Need extra support?

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

Learn More

Forum Channels