poi过滤操作后产生新的sheet

public Sheet filterSheet(Sheet sheetToFilter){
		if(sheetToFilter == null){
			System.out.println("sheetToFilter is null!");
			return null;
		}
		int lastRowNum = sheetToFilter.getLastRowNum();
		int rowIndexI = 0;
		int rowIndexJ = 0;
		while(rowIndexI<=lastRowNum){
			Row row = sheetToFilter.getRow(rowIndexI);
			if(row != null){
				if(isVaildRow(row)){
					if(rowIndexI>rowIndexJ){
						shiftRows(rowIndexI,rowIndexI,rowIndexJ-rowIndexI);
					}
					rowIndexJ++;
				} else{
					removeRow(row);
				}
			}
			rowIndexI++;
		}
		
	}

  虽然能完成功能,但涉及到shiftRows和removeRows,复杂度过高。。。。不推荐使用

posted on 2014-07-22 22:55  -赶鸭子上架-  阅读(400)  评论(0编辑  收藏  举报