// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); // Init data. IRange range = worksheet.getRange("B2:D4"); range.setValue("Unused"); // Select range. IRange selectedRange = worksheet.getRange("C3:E5"); selectedRange.select(); // Get the used range from selectedRange. IRange usedRange = selectedRange.getUsedRange(); usedRange.setValue("Used"); usedRange.getInterior().setColor(Color.GetLightBlue()); // Save to an excel file workbook.save("GetRangeUsedRange.xlsx");