Question

I noticed something interesting when trying to use the library LinqToExcel.

 var factory = new ExcelQueryFactory(@"TestData\myFile.xlsx");

 var model = categoryHandler.GetCategoryTree(factory.Worksheet<MyRow>("WorkSheetName").ToList());

I use the above code to parse the rows of my excel sheet into an object called MyRow. The object has one property per column in the excel sheet. However, what I am noticing is that the library will ignore mixed string and numeric content in my columns. Meaning if the column has numeric content in the first rows, it will ignore/skip any non numeric content in subsequent rows. It almost seems as if the library inspects the first row and assumes that format for the rest of the file. The cells are all formatted as generic, but may contain numeric or regular strings.

Is this expected behavior?

Était-ce utile?

La solution

The issue has to do with the OLEDB provider which LinqToExcel uses.

Here's a stack overflow question that explains the issue: Excel cell-values are truncated by OLEDB-provider

The article explains that adding HDR=YES helps with the problem, and LinqToExcel already sets that property.

So basically you need to have an alphanumeric room number in the first 8 or 16 rows. Else OLEDB treats all the values in that column as numbers instead of strings.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top