Pergunta

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...

Foi útil?

Solução

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#");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top