If the memory resembles shiftRows(int startRow, int endRow, int n) , then you need to. I donβt quite remember how to check if the row is empty, but if you know that the row is empty (usually using removeRow(Row row) ) and you know rowIndex, then this is not so bad. By calling:
int rowIndex; //Assume already known and this is the row you want to get rid of int lastIndex = sheet.getLastRowNum(); sheet.shiftRows(rowIndex + 1, lastIndex, -1);
you change each row in [rowIndex + 1, lastIndex] inclusively to 1 (which should effectively remove an empty row). If you have multiple lines and you have a way to determine if the line was empty, I suggest something like:
for(int i = 0; i < sheet.getLastRowNum(); i++){ if(isEmpty(sheet.getRow(i)){ sheet.shiftRows(i + 1, sheet.getLastRowNum(), -1); i--;
As a small note, if n negative, the lines are shifted up. If n positive, the rows are shifted down. Therefore, I am not entirely sure that you want to move this piece of lines to 500 or not in the code you provided. Hope this helps.
source share