poi 复制并合格单元格

CellRangeAddress region = sheet[sheetNumber].getMergedRegion(0);
  Row row = sheet[sheetNumber].getRow(rowNumber);
  Cell temp = null;
  if (rowNumber == 5 && columnNumber == 2) {
   sheet[sheetNumber].shiftRows(16, 17, 1, true, false);

   region.setLastColumn(region.getLastColumn());
   CellRangeAddress newRegion = region.copy();
   newRegion.setFirstRow(16);
   newRegion.setLastRow(16);
   newRegion.setFirstColumn(2);
   newRegion.setLastColumn(3);
   sheet[sheetNumber].addMergedRegion(newRegion);
   Row row1 = sheet[sheetNumber].getRow(16);
   temp = row1.createCell(2);

   temp.setCellValue(15789);
  }

  /**
   * 得到列对象
   */
  Cell cell = row.getCell(columnNumber);

  /**
   * 判断列对象是否为空
   */
  if (cell == null) {
   cell = row.createCell(columnNumber);
  }

  if (rowNumber == 5 && columnNumber == 2) {
   temp.setCellStyle(cell.getCellStyle());

  }

你可能感兴趣的:(poi 复制并合格单元格)