// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IRange originalRange = worksheet.getRange("B2:D4"); originalRange.merge(); originalRange.setValue("Original Range"); originalRange.getFont().setBold(true); originalRange.getFont().setColor(Color.FromArgb(226, 231, 243)); originalRange.getInterior().setColor(Color.FromArgb(145, 167, 214)); originalRange.setHorizontalAlignment(HorizontalAlignment.Center); originalRange.setVerticalAlignment(VerticalAlignment.Center); // Set the offset of the range value and style. IRange offsetRange = worksheet.getRange("B2:D4").offset(4, 4); offsetRange.merge(); offsetRange.setValue("Offset Range"); offsetRange.getFont().setBold(true); offsetRange.getFont().setColor(Color.FromArgb(226, 231, 243)); offsetRange.getInterior().setColor(Color.FromArgb(56, 93, 171)); offsetRange.setHorizontalAlignment(HorizontalAlignment.Center); offsetRange.setVerticalAlignment(VerticalAlignment.Center); // Save to an excel file workbook.save("RangeOffset.xlsx");