paulyoder / LinqToExcel

Use LINQ to retrieve data from spreadsheets and csv files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

column skiped

no1traveller opened this issue · comments

image

image

var worksheetName = excel.GetWorksheetNames().FirstOrDefault();
columns = excel.GetColumnNames(worksheetName).ToList();
var named=excel.GetNamedRanges(worksheetName);
if (worksheetName != null)
{
    records = excel.Worksheet(worksheetName).ToList();
}

this should be pretty self explanatory. its skipping the first column. this is pretty basic functionality and im disappointed its falling over at this stage.

It would be helpful if you also attach an affected xls/xlsx file as well (I don't need the actual data you're using, just some that presents the same issue). I can just type in the data you've provided in your screenshot, but that doesn't always work in reproducing the issue.

I've Attached the file

I will try to look at this today.

I don't see any attachments.

Anyway, as I suspected, when filling in a spreadsheet myself, I do not see the issue you're talking about.

image

I need more to go on than you've given me.

  1. What version of LinqToExcel are you using?
  2. 32 or 64 bit?
  3. ACE or Jet?
  4. Please attach a spreadsheet that has the problem.
  5. Please attach a project/solution that exhibits this behaviour. Your code snippet above is incomplete.

Also, you don't indicate which variable you're inspecting. I had to assume it was "records".

I'm experiencing a similar issue, although based on my testing it appears to be skipping the first column if all of the cells are empty. In the linked file, if I change cell A1 to be a single space character, it finds the column. Otherwise, it does not.

This makes it difficult to use across a large set of files that all have the same template (but don't adhere to mappable format), as the columns may be shifted depending on their content.

Answering your questions from above:

LinqToExcel 1.11.0

  1. LinqToExcel 1.11.0
  2. 32 bit (on a 64 bit machine)
  3. Default (Jet)
  4. GitHub won't allow attaching a .XLS, can be downloaded here
  5. Running in LINQPad 5 as "C# Statement(s)", but will try in VS2019 if you are unable to reproduce:
    var excel = new ExcelQueryFactory(@"Path\to\BadFirstColumn.xls"); var worksheet = excel.WorksheetNoHeader("Sheet1"); Console.WriteLine("Cell E1 should be empty."); Console.WriteLine($"Cell E1 contents: {worksheet.First()[4].Value}"); try { Console.WriteLine("Cell F1 should have content:"); Console.WriteLine($"Cell F1 contents: {worksheet.First()[5].Value}"); } catch(ArgumentOutOfRangeException) { Console.WriteLine("Cell F1 does not exist."); }