部分代码如下(POI的版本为3.2)
public void insertRow() throws IOException {
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("workbook.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheet("new sheet");
int starRow = 4;
int rows = 5;
sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows,true,false);
//Parameters:
//startRow - the row to start shifting
//endRow - the row to end shifting
//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
starRow = starRow - 1;
for (int i = 0; i < rows; i++) {
HSSFRow sourceRow = null;
HSSFRow targetRow = null;
HSSFCell
最后
以上就是有魅力书包最近收集整理的关于java excel 插入新行_使用POI往EXCEL中插入行的全部内容,更多相关java内容请搜索靠谱客的其他文章。
发表评论 取消回复