Numbers Formatting on Cells.
Previous | Home | Next |
Numbers Formatting on Cells.
To perform formatting on the Numbers we will be using the following class,
public class NumberFormat extends jxl.write.biff.NumberFormatRecord implements jxl.biff.DisplayFormat
It is a custom user defined number format, which can be instantiated within user applications
in order to present numerical values to the optimum level of accuracy. The string format
used to create a number format abides to the standard java specification. JExcelAPI
makes the necessary modifications so that it is used in Excel as the nearest possible equivalent.
After it get created this may be used within a CellFormat object, which in turn is a parameter passed
to the constructor of the Number cell.
WritableCellFormat wcf1=new WritableCellFormat(NumberFormats.DEFAULT);
wcf1.setAlignment(Alignment.LEFT);
wcf1.setShrinkToFit(true);
wcf1.setWrap(true);
Number num=new Number(1,1,4.567778, wcf1);
sheet.addCell(num);
In the above code snippet we have passed the writablecellformat object to the constructor of the Number class and after that we have add that number to the worksheet.
Previous | Home | Next |