facebooktwittermenuarrow-up

GemBox Support Forum

Reading a specific cell in an Excel file

I’m just getting my feet wet with GemBox, and I’m looking at the Reading example. Is there a way just to read a specific cell in an excel file I.E. (E,10)? The example shows it reading in the whole file.

Thanks

Hi Larry,

Yes, you can read any specific cell like the following:

ExcelFile workbook = ExcelFile.Load("input.xlsx");
ExcelWorksheet worksheet = workbook.Worksheets["Sheet1"];
ExcelCell cell = worksheet.Cells["E10"]
Console.WriteLine(cell.Value);

Or the following:

ExcelFile workbook = ExcelFile.Load("input.xlsx");
ExcelWorksheet worksheet = workbook.Worksheets[0];
ExcelCell cell = worksheet.Cells[9, 4];
Console.WriteLine(cell.Value);

Or you could check the Cell Referencing example which shows additional ways how you can retrieve the desired cell or cells, like using column name “E” and row index 9.

I hope this helps.

Regards,
Mario