我一直在尝试我的代码来删除我的Excel文件中的空行!我的代码是:无法删除使用Apache POI的空行Excel文件
private void shift(File f){
File F=f;
HSSFWorkbook wb = null;
HSSFSheet sheet=null;
try{
FileInputStream is=new FileInputStream(F);
wb= new HSSFWorkbook(is);
sheet = wb.getSheetAt(0);
for(int i = 0; i < sheet.getLastRowNum(); i++){
if(sheet.getRow(i)==null){
sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1);
i--;
}
}
FileOutputStream fileOut = new FileOutputStream("C:/juni1.xls");
wb.write(fileOut);
fileOut.close();
//Here I want to write the new update file without empty rows!
}
catch(Exception e){
System.out.print("SERRO "+e);
}
}
该代码根本没有任何效果。任何机构可以告诉我什么是问题,请帮助我,我一直试图做的事情,因为过去10个小时。提前致谢!