Column.CellType is different to Cells.CellType

Posted by: jcast07 on 8 September 2017, 1:27 pm EST

  • Posted 8 September 2017, 1:27 pm EST


     I have the following:

    QCLimitSpread_Sheet1.Columns(11).CellType = m_DateTimeCellType, where m_DateTimeCellType is DateTimeCellType

    If I look at  QCLimitSpread_Sheet1.Cells(0,11).CellType it returns nothing, but if I look at QCLimitSpread_Sheet1.Columns(11).CellType I get the DateTimeCellType object.

    Should the individual cells have the same CellType?

  • Replied 8 September 2017, 1:27 pm EST


    The behavior you are seeing is correct. Each object (cell, column, row, sheet) is seperate but composited togerther to display in the cell. If you set the CellType on the column, then the Cells.CellType object would be nothing. You can compose the StyleInfo from the different objects to determine what will actually be displayed in the cell. You can use the GetCellType method to do this or GetCompositeInfo method on the StyleModel.

  • Replied 8 September 2017, 1:27 pm EST

    After binding does the type of the data from the datasource get applied to the celltype of the cells?
  • Replied 8 September 2017, 1:27 pm EST

    I am noticing something that I think is not consistent and it is the following.

    After I bind data to a spread sheet. I set the celltype as DateTimeCellType for a range of cells in a column.

    If I paste from the clipboard a string or a number of type double to the DateTime cell it does not change anything, which I expected. But when I copy to a cell with no data within the range of cells which I set, there is a different behavior. It works the same as described previously when I try to copy a string, but when I try to copy a double I get a date of 1/4/1900 12:00:00 AM.

    Is this a problem with spread or am I missing something here?

  • Replied 8 September 2017, 1:27 pm EST


    When data is copied to a cell of a particular celltype, the Parse method of that celltype is called to parse the data to put in the DataModel. If your double value that yuo are pasting can be parsed as a Serial date, then it will paste into the DateTimeCellType with no problem.

Need extra support?

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

Learn More

Forum Channels