I need a way to insert new cells and/or rows between pre-existing rows without deleting any of the rows.
I tried using:
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();
}
But unfortunately it deletes some rows down the line to accommodate the shift. The deleted rows seem to be random they aren't actually directly below the shifted rows or above. They seem to happen inbetween shifted rows if I shift more than one row.
Thank you in advance for your help.