POI shiftRows方法

public void ShiftRows(int startRow, int endRow, int n);
public void ShiftRows(int startRow, int endRow, int n, bool copyRowHeight, bool resetOriginalRowHeight);
public void ShiftRows(int startRow, int endRow, int n, bool copyRowHeight, bool resetOriginalRowHeight, bool moveComments);

        //Parameters:
        //startRow - the row to start shifting(从下标为startRow的行开始移动)
        //endRow - the row to end shifting(到下标为endRow的行结束移动)
        //n - the number of rows to shift(有多少行需要移动)
        //copyRowHeight - whether to copy the row height during the shift
        //resetOriginalRowHeight - whether to set the original row's height to the default

 

如:

sheet.shiftRows(insertRow, sheet.getLastRowNum(),1,true,false);
                row=sheet.createRow(insertRow);

 

先把insertRow到最后一行向下移动一行,在移动后的insertRow处(移动后留的空白),新建一个新行,这样就实现了数据行的插入

 

posted @ 2016-12-01 16:01  StaticXy  阅读(25075)  评论(1编辑  收藏  举报