package com.read; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.ArrayList; import javax.naming.spi.ObjectFactory; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.*; @SuppressWarnings("serial") public class Newjava implements java.io.Serializable{ @SuppressWarnings("deprecation") public ObjectFactory createFactory(String file) { System.out.println("file - " +file); ArrayList<newjava> arr=new ArrayList<newjava>(); try{ //FileInputStream file1=new FileInputStream("//home//suvi//ATMInformation.xlsx"); XSSFWorkbook workbook=new XSSFWorkbook(file); XSSFSheet sheet=workbook.getSheetAt(0); Iterator<row> rowIterator=sheet.iterator(); while(rowIterator.hasNext()) { Row row=rowIterator.next(); Iterator<cell> cellIterator=row.cellIterator(); System.out.println("\n Row Number: "+row.getRowNum()); while(cellIterator.hasNext()) { Cell cell=cellIterator.next(); switch(cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: System.out.print(cell.getNumericCellValue() +"\t"); break; case Cell.CELL_TYPE_STRING: System.out.print(cell.getStringCellValue() +"\t");break; } } System.out.print(" "); } FileOutputStream out=new FileOutputStream("//home//suvi//ATMInformation.xlsx"); workbook.write(out); out.close(); } catch(FileNotFoundException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } return null; } /*public static void main(String[] args) { // TODO Auto-generated method stub Newjava obj=new Newjava(); }*/ }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)