在使用poi包进行操作excel的时候,出现在两次for循环中,无法正确写入excel现象
XSSFWorkbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("result");
for (int i = 0;i< 79;i++){
for(int j= 1;j<4;j++){
sheet.createRow(i).createCell(0).setCellValue("当前i:"+i);
sheet.createRow(i).createCell(j).setCellValue("当前j:"+j);
}
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(McUtils.compareResult_str + "C666.xlsx");
wb.write(fos);
} catch (IOException e) {
System.out.println(e.toString());
} finally {
try {
fos.close();
} catch (IOException e) {
System.out.println(e.toString());
}
}
1、是不能用两次for循环,还是其他原因?
2、for循环中有两句setValue,但是只有后一句生效了,并且后一句只写入了最后一列(即只有j=3的时候生效了),这是什么原因