0

So I'm using C# to read through an Excel (.xlsm) file, everything is fine... Until all I want to do is read one column. That's all I want to do, some sample code here:

Worksheet sheet = (Worksheet)workBookIn.Sheets[sheetName];
Range r =
    sheet.get_range("B2", sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell));
Array vals = pitch.Cells.Value;

Also, if anyone could suggest a more elegant approach to the latter part of the code (i.e. processing the range of Excel values), please feel free to comment.

Tyler Lee
  • 2,736
  • 13
  • 24
user1092809
  • 107
  • 1
  • 7

1 Answers1

2
Worksheet sheet = (Worksheet)workBookIn.Sheets[sheetName];
Range r =
    sheet.get_range("B2", "B" + sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Row);
Array vals = pitch.Cells.Value;
InContext
  • 2,461
  • 12
  • 24