Hi all,
I use C# to automate an excel file. I was able to get the workbook and the sheets it contains. If for example I have in sheet1 two cols and 5 rows. I wanted o get the range for the occupied cells as A1:B5. I tried the following code but it did not give the correct result. the columns # and row # were much bigger and the cells were empty as well.
Excel.Range xlRange = excelWorksheet.UsedRange;
int col = xlRange.Columns.Count;
int row = xlRange.Rows.Count;
Is there another way I can use to get that range? I would appreciate your help. Thanks in advance, Sarah