0
我需要一种方法在预先存在的行之间插入新的单元格和/或行,而不删除任何行。Apache POI移位行
我试着使用:
public static void addRow(File f, int amount, int currentRow)
throws Exception {
FileInputStream file = new FileInputStream(f);
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
sheet.shiftRows(currentRow, currentRow + amount, amount, true, true);
file.close();
FileOutputStream out = new FileOutputStream(f);
workbook.write(out);
out.close();
}
但不幸的是它会删除一些行的路线,以适应变化。被删除的行似乎是随机的,它们实际上并不直接位于移位行或以上的位置。如果我移动了多行,它们似乎发生在两个移位行之间。
非常感谢您的帮助。
http://stackoverflow.com/questions/5785724/how-to-insert-a-row-between-two-rows-in-an-existing -excel与 - HSSF-Apache的POI – user432