POI api Projects

POI api Project 1

Working with different typeof cell in POI API
Previous Home Next


This page is contain an example of the POI in which we are going to described how to work on the different type of the cell in any sheet. for performing this type of work POI provide the special function setCellType(). which is used to set the type of cell in sheet.

 First of all we are going to create the workbook  and then create a sheet in those workbook. after creation of  the sheet, create the cell and set the type of those cells by the method of the setCellType(Cell.CELL_TYPE_ERROR).


Workbook wkb =
new HSSFWorkbook(); Sheet sht = wkb.createSheet("new sheet"); Row r1 = sht.createRow((short)2); r1.createCell(0).setCellValue(1.1); r1.createCell(1).setCellValue(new Date(0)); r1.createCell(2).setCellValue(Calendar.getInstance()); r1.createCell(3).setCellValue("a string"); r1.createCell(4).setCellValue(true); r1.createCell(5).setCellType(Cell.CELL_TYPE_ERROR); // Write the output to a file FileOutputStream fOut = new FileOutputStream("workbook.xls"); wkb.write(fOut); fOut.close();


Previous Home Next