When you do Excel templates, you will encounter the number of template rows is not fixed, such as the need to insert a row below 4
The workaround is to use the Shifrows method, where the 1th parameter refers to the row to start inserting, and the 2nd argument is the end line number
// omit the preceding data insert operation, the following is the insertion of the 4th row, the 4th line is unchanged, the dynamic Move Down if (i > 3) { truefalse);
}
...
Hssfcell cell1 = Row.getcell (0) = = null? Row.createcell (0): Row.getcell (0);
The rest of the line is also based on the number of rows, the row index dynamically plus the number of rows, which becomes the following
The extra rows are not copied, and the style of the previous line can be taken out first, copied to the new row
POI Excel Inserts a new line, the following action state moves