LinqToExcel icon indicating copy to clipboard operation
LinqToExcel copied to clipboard

Failure to map columns with square brackets in the header row

Open JeremyMahieu opened this issue 5 years ago • 1 comments

I have an excel that looks like in the screenshot. image TestFileHeaders.xlsx

My mapping class looks like this.

public class UnitExcelRow
    {
        [ExcelColumn("barcode")]
        public string Barcode { get; set; }

        [ExcelColumn("gross [ kg]")]
        public string GrossWeight { get; set; }
    }

And the code looks like this:

var unitRaw = excel.Worksheet<UnitExcelRow>(0) // 0 for first worksheet<
  .ToList(); 

I only get null for GrossWeight. I'm not sure why it's not working, if I change the header to "test" it works. I assume it's the square brackets that are not working.

JeremyMahieu avatar May 19 '20 08:05 JeremyMahieu

In a similar vein, I have a column header "Date/Time" and when I trying to select and filter on that column "from c in worksheet where c["Date/Time"] <... it comes back with an error that "..."Date/Time" is not a valid column name. Valid column names are... xxx, "Date/Time", yyy..."

CPerry-COV avatar Sep 08 '21 18:09 CPerry-COV