Create freeze panes on Excel Sheet Using JExcel APIs.
Previous | Home | Next |
In this part of the tutorial we will learn how to freeze panes on Excel Sheet Using JExcel APIs.
To create the horizontal and vertical freeze panes on the excel worksheet first we will have to import the jxl.SheetSettings class.
For creating the horizontal and vertical freeze panes the jxl.SheetSettings class contains the following methods,
public void setVerticalFreeze(int col)
This method sets the row at which the pane is frozen vertically.
col -> to freeze at the column
public void setHorizontalFreeze(int row)
Sets the row at which the pane is frozen horizontally
row -> to freeze at the row
The following code snippet will show you how to use the above defined methods,
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 lblName=new Label(0,0,"Names"); // created different labels
Label lblFloatNum1=new Label(1,0,"Floatnum1");
Label lblFloatNum2=new Label(2,0,"Floatnum2");
Label lblFormula=new Label(3,0,"Formulas");
sheet.addCell(lblName); // adding labels to the cell
sheet.addCell(lblFloatNum1);
sheet.addCell(lblFloatNum2);
sheet.addCell(lblFormula);
sheet.getSettings().setVerticalFreeze(2); // applied vertical freeze at column 2
workbook.write();
workbook.close();
Previous | Home | Next |