Set the zoom magnification for a sheet on Excel Sheet Using JExcel APIs.

Set the zoom magnification for a sheet on Excel Sheet Using JExcel APIs.

Previous Home Next

 

In this part we will be setting the zoom magnification for a sheet on Excel Sheet Using JExcel APIs.

For performing the zoom manification on an excel sheet using the JExcel API, we have to import the jxl.SheetSettings class. It has mainly two constructor which are used,

SheetSettings(Sheet sht)
This is the default constructor.

SheetSettings(SheetSettings copy, Sheet sht)
It is the copy constructor constructor and is used when we are copying the sheets.
 
 For setting the zoom magnification in an excel sheet we have to use the setzoomFactor(int zmf) method contained in the jxl.SheetSettings() class, where zmf is the argument which tell the zoom factor in percentage. The following code snippet will demonstrate you how can we set zoom magnification on the 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 lblName=new Label(0,0,"Names");   // created a label named Names
sheet.addCell(lblName);                 // added the label to the cell
sheet.getSettings().setzoomFactor(150);  // we have set the zoomFactor to the percentage of 150
workbook.write();        // writting the data to the workbook
workbook.close();        // closing the workbook


 

Previous Home Next