I am trying to set a data type for a cell in CLosedXML, however the answers I have found about my problem all rely on Cell.SetDataType(x)
or Cell.DataType = x
and both of them seem to be impossible for me for some reason.
Some pages with answers I found:
https://codingjump.com/posts/closedxml-openxml-setting-data-type-for-cell
How to set a data type for a column with ClosedXML?
https://github.com/ClosedXML/ClosedXML/wiki/Data-Types
And ALL OF THEM answer as if my problem does not exist for them.
Whenever I attempt to call Cell.SetDatatype(XLDataType.Text)
I get the following error:
Error CS1061 'IXLCell' does not contain a definition for 'SetDataType' and no accessible extension method 'SetDataType' accepting a first argument of type 'IXLCell' could be found (are you missing a using directive or an assembly reference?)
And whenever I attempt to use Cell.DataType = XLDataType.Text
I get this:
Error CS0200 Property or indexer 'IXLCell.DataType' cannot be assigned to -- it is read only
How would I set a cell's data type if it is read only?
With version 0.100 you don't need to set a datatype for a cell, because the type of the cell value will be used. The pages you found are for older versions (page 2 has been updated now).
From the migration guide:
SetDataType methods removed
Method SetDataType has been removed from all interfaces (IXLCell, IXLColumn, IXLColumns, IXLRange …). There is no replacement, if you need to reinterpret existing data, do it in application code and set a new value with a specific type.