我正在尝试覆盖excel中的数据,但它只写入最后一行和列,而我想要的是覆盖所有内容。
这是我的代码。
for(int i=0; i < 139; i++){
for(int j=0; j < 9; j++){
HSSFRow read_row = worksheet.getRow(i);
HSSFCell read_cell = read_row.getCell(j);
if(read_cell.equals(null)){
read_cell.setCellValue("0");
}
System.out.println("row: " + i + " cell: " + read_row.getCell(j));
HSSFSheet worksheet1 = hwb1.getSheetAt(sheetNum);
worksheet1.createRow(i).createCell(j);
HSSFRow write_row = worksheet1.getRow(i);
HSSFCell write_cell = write_row.getCell(j);
write_cell.setCellValue(read_cell.getStringCellValue());
}
}