Reading and Writing the sheet of workbook using POI API

Reading and Writing the sheet of workbook using POI API

Previous Home Next

 

In this page of the example we are try to show you how we can write the data in excel sheet and how we can read this data by the help of the POI API's. POI provide the WorkbookFactory.create() method. by this method we can create the factory of workbook. 


 


 

InputStream
ip = new FileInputStream("workbook.xls"); Workbook wkb = WorkbookFactory.create(ip); Sheet sit = wkb.getSheetAt(0); Row row = sit.getRow(2); Cell cell = row.getCell(3); if (cell == null) cell = row.createCell(3); cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue("a test"); // Write the output to a file FileOutputStream fo = new FileOutputStream("workbook.xls"); wkb.write(fo); fo.close();

 


Previous Home Next