I am trying to delete rows from an excel file using this code
- Code: Select all
if (centerList.contains(center))
{
calculationList.add(new Long(r.getR()));
rows.remove(r);
i--;
total_rows--;
old_R--;
removal = true;
centerList.remove(center);
}
by rows.remove(r) line.
But this only clears the row.
So I also have to move the cells to one row above after remove, which I do by this.
- Code: Select all
for (Cell cr : r.getC())
{
String str = cr.getR();
str = str.replaceAll("[0-9]+", new Long(old_R+1).toString());
cr.setR(str);
}
r.setR(old_R+1);
But In the end I end up losing a lot of formulas in the end rows. My file has 40k rows and formula is retained in randomly 55-65 rows in the top.
How do I take care of the formulas of the rows that I want to maintain?