private static void insertRow(Sheet sheet, int starRow, int rows)
{
sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false);
starRow = starRow - 1;
for (int i = 0; i < rows; i++) {
Row sourceRow = null;
Row targetRow = null;
Cell sourceCell = null;
Cell targetCell = null;
short m;
starRow = starRow + 1;
sourceRow = sheet.getRow(starRow);
targetRow = sheet.createRow(starRow + 1);
targetRow.setHeight(sourceRow.getHeight());
for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++)
{
System.out.println( "m:------>" + m);
sourceCell = sourceRow.getCell(m);
targetCell = targetRow.createCell(m);
targetCell.setCellStyle(sourceCell.getCellStyle());
targetCell.setCellType(sourceCell.getCellType());
}
}
}
{
sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false);
starRow = starRow - 1;
for (int i = 0; i < rows; i++) {
Row sourceRow = null;
Row targetRow = null;
Cell sourceCell = null;
Cell targetCell = null;
short m;
starRow = starRow + 1;
sourceRow = sheet.getRow(starRow);
targetRow = sheet.createRow(starRow + 1);
targetRow.setHeight(sourceRow.getHeight());
for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++)
{
System.out.println( "m:------>" + m);
sourceCell = sourceRow.getCell(m);
targetCell = targetRow.createCell(m);
targetCell.setCellStyle(sourceCell.getCellStyle());
targetCell.setCellType(sourceCell.getCellType());
}
}
}