poi_insertrow

Today i need to write some code about  import/export the excel by using poi,at first i find the addrow,createrow method,but didn't find insertrow method which was the most wonderful thing i'm looking for,i'm really dispointed.why apache projecters didn't  realizate it. at last I found the shiftRows method instead,it's great.

 if(baseIndex >3){
     //auto move the rows

     sheetArrays[index].shiftRows(19+baseIndex, rowNum+intFileRowNum, 1,true,false);
     row =  sheetArrays[index].createRow(19+baseIndex);
     for(int i=0;i<7;i++){
      cell = row.createCell((short)i);
      cell.setCellStyle(getDataStyle(recordWorkbook,HSSFCellStyle.ALIGN_LEFT));
      if(i == 1){
       cell.setEncoding(HSSFCell.ENCODING_UTF_16);
       cell.setCellValue(1+baseIndex);
       cell.setCellStyle(getDataStyle(recordWorkbook,HSSFCellStyle.ALIGN_CENTER));
      }else if(i==2){
           AjTBaseFile ajTBaseFile=(AjTBaseFile)baseFileList.get(baseIndex);
        cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue(ajTBaseFile.getfile_name());
      }
     }
     row.setHeight((short)440);
     sheetArrays[index].addMergedRegion(new Region(19,(short)0,19+baseIndex,(short)0));
     sheetArrays[index].addMergedRegion(new Region(19+baseIndex,(short)2,19+baseIndex,(short)6));
     intFileRowNum += 1;
    }else{
     row = sheetArrays[index].getRow(19+baseIndex);
        AjTBaseFile ajTBaseFile=(AjTBaseFile)baseFileList.get(baseIndex);
        cell = row.getCell((short)2);
     cell.setEncoding(HSSFCell.ENCODING_UTF_16);
     cell.setCellValue(ajTBaseFile.getfile_name());
     }

ok,that's all.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值