-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional parameter to force column Data Type #457
base: develop
Are you sure you want to change the base?
Conversation
Hi and thank you! Unfortunately I believe this is a problematic change. In particular because of Mono, which apparently has slight differences in its DataSet implementation from the "official" ones. See #409 / #73 / #30. Currently by default ExcelDataReader tries to autodetect the type for If you can tell a bit more about your scenario, maybe we can come up with a better solution? |
Hi, this is my scenary. When I read and Excel document that contains an value of type Decimal, it always is save in the DataTable returned by the extensor method as a Double. But in this case I want it as a Decimal cause I'll save the DataTable into the database as Decimal. This is just a specific scenario. But a very common situation is that someone want to read the value from the Excel with an specific data type. Otherwise he/she must retrieve the information from the original DataTable, perform a casting or type conversion and then create a new DataTable to be stored into the Database. This is memory consuming solution obviously. |
Some kind of new Alternatively, if you need a quick resolve you might find it easier to build the dataset manually yourself, f.ex by copying the AsDataSet method into your project and adapt+simplify as necessary. AsDataSet() is theoretically quite simple, but comes with lots of bells and whistles. |
To the extension class "ExcelDataReaderExtensions" was added a new optional parameter. This new parameter allow specify the value type associated to a column.
The structure of this parameter is a list of ExcelDataType.
The definition of an ExcelDataType is:
public class ExcelDataType
{
public string ColumnName { get; set; }
public Type ColumnType { get; set; }
}