LinqToExcel icon indicating copy to clipboard operation
LinqToExcel copied to clipboard

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

Open JawadJaber opened this issue 6 years ago • 5 comments

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

JawadJaber avatar May 15 '18 07:05 JawadJaber

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.

Bosti1904 avatar May 24 '18 12:05 Bosti1904

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

JawadJaber avatar May 30 '18 06:05 JawadJaber

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.

Bosti1904 avatar May 30 '18 07:05 Bosti1904

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

JawadJaber avatar May 30 '18 08:05 JawadJaber

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

Kavya27 avatar Nov 11 '20 06:11 Kavya27