Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinqToExcel dot in header

Using linqtoexcel to read a server generated spreadsheet. Only problem is that there is a dot in one of the headers and it refuses to pull. Manufacturer is abbreviated to Mfg. I used the following code per the example on their page

        ExcelQueryFactory excel = new ExcelQueryFactory();
        excel.FileName = myXLFile;
        excel.AddMapping<Part>(x => x.Manufacturer, "Mfg.");
        var parts = from x in excel.Worksheet<Part>(0)
                    select x;

but Manufacturer comes up empty in all the objects. I am very new to Linq so not sure what options I might have to make this work. I imagine it is confused by the dot when it tries to map to a Part object...

like image 680
Dave_750 Avatar asked Oct 23 '13 17:10

Dave_750


1 Answers

As is apparent from this thread in Linq To Excel's discussion group you have to replace the dot by a hash:

excel.AddMapping<Part>(x => x.Manufacturer, "Mfg#");
like image 137
Gert Arnold Avatar answered Sep 20 '22 15:09

Gert Arnold