paulyoder / LinqToExcel

Use LINQ to retrieve data from spreadsheets and csv files
MIT License
1.06k stars 299 forks source link

If the first row was not string, and first value was double, then any string later will be null #145

Open JawadJaber opened 6 years ago

JawadJaber commented 6 years ago

See this stackoverflow case https://stackoverflow.com/a/28862382/4516125

Bosti1904 commented 6 years ago

I have the same problem. Suggestion: When defining the mapping you could also specify a type to which the mapping should "convert" or extend the transformations in that way.

JawadJaber commented 6 years ago

Can you show me an example? Mapping does not work for me.

Bosti1904 commented 6 years ago

My previous comment is not relevant, becasue OleDbDataAdapter "decides" what data types are the columns going to be. Based on my research you can't define a columns's data type when reading from excel (I have downloaded the solution in debugged it and seen how the dataadapter works). Normally it analyses the first 8 rows and defines the data type based on the pattern from this rows. You could change the number of how many rows should he read in the registry but I do not garanty that will work.

In my case there where 3 rows empty, then one had a number and the 5 where empty and the one had a string. So the adapter defined the column as a number which was wrong. The only thing that seem to work for me was to define the cell/column type from "general" to "text", then all the values where read as string.

JawadJaber commented 6 years ago

Thank you very much, this conversion from "general" to "text" worked well with me

Kavya27 commented 3 years ago

Is any other solution for this? that done by some setting in code.