// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); // Auto fit column width of range 'A1' worksheet.getRange("A1").setValue("Document Solutions for Excel"); worksheet.getRange("A1").getColumns().autoFit(); //Auto fit row height of range 'B2' worksheet.getRange("B2").setValue("Document Solutions for Excel"); worksheet.getRange("B2").getFont().setSize(20); worksheet.getRange("B2").getRows().autoFit(); //Auto fit column width and row height of range 'C3' worksheet.getRange("C3").setValue("Document Solutions for Excel"); worksheet.getRange("C3").getFont().setSize(32); worksheet.getRange("C3").autoFit(); // Save to an excel file workbook.save("AutoFit.xlsx");