public void imprime() throws FileNotFoundException, IOException{
sh = wb.getSheet("Dia");
int i = 0;
while (i<=11){
if(i==0){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Master Crédito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==1){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Master Débito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==2){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Visa Crédito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==3){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Visa Débito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==4){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Elo Crédito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==5){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Elo Débito");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==6){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Refeição/Alimentação");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==7){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Online Ifood");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==8){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Voucher IFood");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==9){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("PIX");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==10){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("PicPay");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==11){
wb.setActiveSheet(0);
row = sh.createRow(1);
cell = row.createCell(i);
cell.setCellValue("Dinheiro");
fos = new FileOutputStream("C:/Users/Caio/Desktop/Controle_Diário.xls");
wb.write(fos);
fos.flush();
fos.close();
System.out.println("Done");
i++;
}
if(i==12){
System.out.println("Feito.");
}
}
}
Alguém consegue me ajudar? Estou com esse código, era para ele criar cada categoria em uma planilha, porém ele só escreve a últiima, algúem tem ideia do que seja?