//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet sheet = workbook.Worksheets[0]; // Init data. IRange range = sheet.Range["B2:D4"]; range.Value = "Unused"; // Select range. IRange selectedRange = sheet.Range["C3:E5"]; selectedRange.Select(); // Get the used range from selectedRange. IRange usedRange = selectedRange.UsedRange; usedRange.Value = "Used"; usedRange.Interior.Color = Color.LightBlue;
' Create a new Workbook Dim workbook As New Workbook Dim sheet As IWorksheet = workbook.Worksheets(0) ' Init data. Dim range As IRange = sheet.Range("B2:D4") range.Value = "Unused" ' Select range. Dim selectedRange As IRange = sheet.Range("C3:E5") selectedRange.Select() ' Get the used range from selectedRange. Dim usedRange As IRange = selectedRange.UsedRange usedRange.Value = "Used" usedRange.Interior.Color = Color.LightBlue ' save to an excel file workbook.Save("GetRangeUsedRange.xlsx")