-
Notifications
You must be signed in to change notification settings - Fork 5
Auto Fit Row and Column
shoaibkhan-aspose edited this page Jul 14, 2014
·
2 revisions
InputStream inStream = new FileInputStream("workbook.xls");
Workbook workbook = WorkbookFactory.create(inStream);
Sheet sheet = workbook.createSheet("new sheet");
sheet.autoSizeColumn(0); //adjust width of the first column
sheet.autoSizeColumn(1); //adjust width of the second column
FileOutputStream fileOut;
fileOut = new FileOutputStream("AutoFit_Apache.xls");
workbook.write(fileOut);
fileOut.close();
Workbook workbook = new Workbook("workbook.xls");
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
worksheet.autoFitRow(1); //Auto-fitting the 2nd row of the worksheet
worksheet.autoFitColumn(0); //Auto-fitting the 1st column of the worksheet
//Saving the modified Excel file in default (that is Excel 2003) format
workbook.save("AutoFit_Aspose.xls");
Download Source Code
For further releases and updates, please follow these new repositories:
- Aspose.Words Java for Apache POI
- Aspose.Cells Java for Apache POI
- Aspose.Slides Java for Apache POI
- Aspose.Email Java for Apache POI
- For documentation, please visit Aspose Docs.
- Raise your queries and suggest more examples via Aspose Forums or via new social coding sites.