I posted this on SO, but haven't had any luck so hopefully someone here can help me.
I am working with a client to import a rather larger Excel file (over 37K rows) into a custom system and utilizing the excellent LinqToExcel library to do so. While reading all of the data in, I noticed it was breaking on records about 80% in and dug a little further. The reason it fails is the majority of records (with associated dates ranging 2011 - 2015) are normal, e.g. 1/3/2015, however starting in 2016, the structure changes to look like this: '1/4/2016 (note the "tick" at the beginning of the date) and LinqToExcel starts returning a DBNull for that column.
Here is a small code snippet:
var excel = new LinqToExcel.ExcelQueryFactory(Path.Combine(this.FilePath, this.CurrentFilename)); foreach (var row in excel.Worksheet(file.WorksheetName)) { //the "row" variable here, which is a LinqToExcel.Row instance, doesn't have the value - it's empty data.Add(this.FillEntity(row)); }
Any ideas on why it would do that and ways around it? Note that this isn't a casting issue - I can use the Immediate Window to see all the values of the LinqToExcel.Row value and where that column index is, the value is empty. I'm also not using generics to fill the class - the value isn't filled by LinqToExcel itself, so I'm not sure where to begin on resolving that.
I posted this on SO, but haven't had any luck so hopefully someone here can help me.
I am working with a client to import a rather larger Excel file (over 37K rows) into a custom system and utilizing the excellent LinqToExcel library to do so. While reading all of the data in, I noticed it was breaking on records about 80% in and dug a little further. The reason it fails is the majority of records (with associated dates ranging 2011 - 2015) are normal, e.g.
1/3/2015
, however starting in 2016, the structure changes to look like this:'1/4/2016
(note the "tick" at the beginning of the date) and LinqToExcel starts returning a DBNull for that column.Here is a small code snippet:
var excel = new LinqToExcel.ExcelQueryFactory(Path.Combine(this.FilePath, this.CurrentFilename)); foreach (var row in excel.Worksheet(file.WorksheetName)) { //the "row" variable here, which is a LinqToExcel.Row instance, doesn't have the value - it's empty data.Add(this.FillEntity(row)); }
Any ideas on why it would do that and ways around it? Note that this isn't a casting issue - I can use the Immediate Window to see all the values of the LinqToExcel.Row value and where that column index is, the value is empty. I'm also not using generics to fill the class - the value isn't filled by LinqToExcel itself, so I'm not sure where to begin on resolving that.