List of usage examples for org.apache.poi.ss.util CellRangeAddressList addCellRangeAddress
public void addCellRangeAddress(CellRangeAddress cra)
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
private void addCommentStatus(Sheet p_sheet, Set<Integer> rowsWithCommentSet, int last_row) { DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraintAll = null; DataValidationConstraint dvConstraintOne = null; CellRangeAddressList addressListOne = new CellRangeAddressList(); CellRangeAddressList addressListAll = new CellRangeAddressList(); CellRangeAddress cellAddress = null; List<String> status = new ArrayList<String>(); status.addAll(IssueOptions.getAllStatus()); String[] allStatus = new String[status.size()]; status.toArray(allStatus);//www . j a v a2 s .co m dvConstraintAll = dvHelper.createExplicitListConstraint(allStatus); String[] oneStatus = { Issue.STATUS_QUERY }; dvConstraintOne = dvHelper.createExplicitListConstraint(oneStatus); if (rowsWithCommentSet.size() == 0) { cellAddress = new CellRangeAddress(SEGMENT_START_ROW, last_row - 1, COMMENT_STATUS_COLUMN, COMMENT_STATUS_COLUMN); addressListOne.addCellRangeAddress(cellAddress); addCommentStatusValidation(p_sheet, dvHelper, dvConstraintOne, addressListOne); } else { boolean hasComment = false; int startRow = SEGMENT_START_ROW; int endRow = -1; for (int row = SEGMENT_START_ROW; row < last_row; row++) { if (rowsWithCommentSet.contains(row)) { if (!hasComment && row != SEGMENT_START_ROW) { endRow = row - 1; cellAddress = new CellRangeAddress(startRow, endRow, COMMENT_STATUS_COLUMN, COMMENT_STATUS_COLUMN); addressListOne.addCellRangeAddress(cellAddress); startRow = row; } hasComment = true; } else { if (hasComment) { endRow = row - 1; cellAddress = new CellRangeAddress(startRow, endRow, COMMENT_STATUS_COLUMN, COMMENT_STATUS_COLUMN); addressListAll.addCellRangeAddress(cellAddress); startRow = row; } hasComment = false; } if (row == last_row - 1) { cellAddress = new CellRangeAddress(startRow, last_row - 1, COMMENT_STATUS_COLUMN, COMMENT_STATUS_COLUMN); if (hasComment) { addressListAll.addCellRangeAddress(cellAddress); } else { addressListOne.addCellRangeAddress(cellAddress); } } } addCommentStatusValidation(p_sheet, dvHelper, dvConstraintAll, addressListAll); addCommentStatusValidation(p_sheet, dvHelper, dvConstraintOne, addressListOne); } }
From source file:de.jlo.talendcomp.excel.SpreadsheetOutput.java
License:Apache License
private CellRangeAddressList createNewAppendingCellRangeAddressList( CellRangeAddressList originalAddressRangeList, int newLastRowIndex) { CellRangeAddressList extendedCellRangeAddressList = new CellRangeAddressList(); for (CellRangeAddress ca : originalAddressRangeList.getCellRangeAddresses()) { extendedCellRangeAddressList.addCellRangeAddress(createAppendingCellRangeAddress(ca, newLastRowIndex)); }//w ww.jav a 2 s . c o m return extendedCellRangeAddressList; }