How to adjust column width to fit the contents on Excel Sheet Using JExcel APIs.
Previous | Home | Next |
In this tutorial we will learn how to adjust column width to fit the contents on Excel Sheet Using JExcel APIs.
For adjusting the column width against the contents on the Excel Sheet using JExcel API, we have to use the jxl.SheetSettings class.
For adjusting the column width against the contents on the Excel Sheet using JExcel API, we have to use the jxl.SheetSettings class. In this class we have the method setDefaultColumnWidth(int) which sets the default coloumn width specified by integer value in the method. The following code snippet will show you how to change the column width in an excel sheet,
WritableWorkbook workbook=Workbook.createWorkbook(new File("F:/JAVA PROJECTS/Jexcel/src/r4r/co/in/firstsheet.xls")); // created a workbook
WritableSheet sheet=workbook.createSheet("mysheet", 0); // created a sheet
Label lbl=new Label(0,0,"Label"); // created a label
sheet.addCell(lbl); // added the label to the sheet
sheet.getSettings().setDefaultColumnWidth(12); //set the DefaultColumnWidth to 12 points
Previous | Home | Next |