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