poi 删除一列

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

public static void removeColumn(XSSFSheet sheet, int removeColumnNum, int removeColumnTotal){
		  if(sheet == null){
		   return;
		  }
		  for (Iterator rowIterator = sheet.rowIterator(); rowIterato
 
r.hasNext();) {
		          XSSFRow row = (XSSFRow)rowIterator.next();
		         XSSFCell cell = row.getCell(removeColumnNum);
		         if(cell == null){
		          continue;
		         }
		          row.removeCell(cell);
		         
//		          for(int n = removeColumnNum; n < (removeColumnTotal + removeColumnNum); n ++){
//		           int columnWidth = sheet.getColumnWidth(n + 1);
//		           
//		           XSSFCell cell2 = row.getCell(n + 1);
//		           
//		           if(cell2 == null){
//		            break;
//		           }
//		           sheet.setColumnWidth(n, columnWidth);
//		           row.moveCell(cell2, (short)n);
//		          }
		  }
		 }

转载于:https://my.oschina.net/u/3503613/blog/1506564

你可能感兴趣的:(java,python,c#)