Hello guys i am a newbie on java poi library and i was trying all my luck to learn this library but still no luck
I would like to have this output
Excel1.xls has this data
ZIP CODE | PLACE | DATE
211
and I want to copy the all the first row data.
ZIP CODE | PLACE | DATE
and place it to another sheet
This is the code that i have made
public static void main(String[] args) throws IOException{
try {
FileInputStream file = new FileInputStream(new File("d:\\input.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFSheet zip1 = workbook.createSheet("ZIP CODE 1");
for(Row row : sheet){
int i=0;
for(Cell cell : row){
cell.setCellType(Cell.CELL_TYPE_STRING);
System.out.print(cell.getStringCellValue() + "\t");
String a = cell.getStringCellValue();
cell = zip1.createRow(i).createCell(i);
i++;
cell.setCellValue(a);
}
break;
}
file.close();
FileOutputStream outFile =new FileOutputStream(new File("d:\\output.xls"));
workbook.write(outFile);
outFile.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}