简体   繁体   中英

Select only one column values from Excel

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 (ie processing the range of Excel values), please feel free to comment.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM