I had the same problem. If I delete the rows manually, the number of rows will not decrease anyway when I checked the use of sheet.getPhysicalNumberOfRows ().
When I deeply dealt with this problem, I found the exact problem. I had an email column in my row, and when I entered an email address, MS Office automatically detects this as an email address. And when I delete this entire line manually, the cell on which the email address was saved still has a value of "(it will not be visible, but I found that the value is initialized when I read it through java). Since this the cell has a non-empty value (""), this entire line is declared (sort of), and the number of lines increases.
The funny thing is that when I do not enter the email address and just enter some line and then delete the line, the cell does not receive initialization and actually ROWCOUNT GOT DECREASED . This is what I found as a result of my problem.
Finally, I decided that not only adding a zero check for the cells, but also
if(cell != "")
Hope this can be helpful for you.
source share