List of usage examples for org.apache.poi.ss.usermodel Sheet addValidationData
public void addValidationData(DataValidation dataValidation);
From source file:com.globalsight.everest.qachecks.QAChecker.java
License:Apache License
private void addFalsePositiveValidation(Sheet p_sheet, int p_lastRow) { DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dvHelper .createExplicitListConstraint(new String[] { FALSE_POSITIVE_YES, FALSE_POSITIVE_NO }); CellRangeAddressList addressList = new CellRangeAddressList(ROW_SEGMENT_START, p_lastRow, COLUMN_FALSE_POSITIVE, COLUMN_FALSE_POSITIVE); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true);/*from www . j a va 2 s .c o m*/ p_sheet.addValidationData(validation); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.CommentsAnalysisReportGenerator.java
License:Apache License
/** * Add category failure drop down list. It is from "J8" to "Jn". * /*from ww w .j a v a 2 s .c om*/ * @param p_sheet * @param startRow * @param lastRow * @param startColumn * @param lastColumn */ private void addCategoryFailureValidation(Sheet p_sheet, int startRow, int lastRow, int startColumn, int lastColumn) { // Add category failure drop down list here. DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dvHelper .createFormulaListConstraint(CATEGORY_FAILURE_DROP_DOWN_LIST); CellRangeAddressList addressList = new CellRangeAddressList(startRow, lastRow, startColumn, lastColumn); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true); p_sheet.addValidationData(validation); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
private void addMarketSuitabilityValidation(Sheet p_sheet, int startRow, int lastRow, int startColumn, int lastColumn) { // Add category failure drop down list here. DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dvHelper.createFormulaListConstraint(MARKET_SUITABILITY_LIST); CellRangeAddressList addressList = new CellRangeAddressList(startRow, lastRow, startColumn, lastColumn); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true);/*from ww w.j a v a 2 s . co m*/ p_sheet.addValidationData(validation); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
private void addQualityAssessmentValidation(Sheet p_sheet, int startRow, int lastRow, int startColumn, int lastColumn) { // Add category failure drop down list here. DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dvHelper.createFormulaListConstraint(QUALITY_ASSESSMENT_LIST); CellRangeAddressList addressList = new CellRangeAddressList(startRow, lastRow, startColumn, lastColumn); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true);/* ww w . j a va 2s . c o m*/ p_sheet.addValidationData(validation); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
private void addCommentStatusValidation(Sheet p_sheet, DataValidationHelper dvHelper, DataValidationConstraint dvConstraint, CellRangeAddressList addressList) { if (addressList == null || addressList.countRanges() == 0) return;//from ww w . j av a 2s .co m DataValidation validationOne = dvHelper.createValidation(dvConstraint, addressList); validationOne.setSuppressDropDownArrow(true); validationOne.setShowErrorBox(true); p_sheet.addValidationData(validationOne); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java
License:Apache License
private void addPriority(Sheet p_sheet, int startRow, int lastRow, int startColumn, int lastColumn) { // Add category failure drop down list here. HashMap priorities = new HashMap(); DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); priorities.putAll(IssueOptions.getAllPriorities()); String[] allpriorities = new String[priorities.size()]; priorities.values().toArray(allpriorities); DataValidationConstraint dvConstraint = dvHelper.createExplicitListConstraint(allpriorities); CellRangeAddressList addressList = new CellRangeAddressList(startRow, lastRow, startColumn, lastColumn); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true);/*from w ww . jav a2s . c o m*/ p_sheet.addValidationData(validation); }
From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ReviewersCommentsReportGenerator.java
License:Apache License
/** * Add comment status drop down list. It is from "K8" to "Kn". * /*from ww w. jav a 2 s.co m*/ * @param p_sheet * @param startRow * @param lastRow * @param startColumn * @param lastColumn */ private void addCommentStatusValidation(Sheet p_sheet, int startRow, int lastRow, int startColumn, int lastColumn) { List<String> status = new ArrayList<String>(IssueOptions.getAllStatus()); String[] statusArray = new String[status.size()]; status.toArray(statusArray); DataValidationHelper dvHelper = p_sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dvHelper.createExplicitListConstraint(statusArray); CellRangeAddressList addressList = new CellRangeAddressList(startRow, lastRow, startColumn, lastColumn); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true); p_sheet.addValidationData(validation); }
From source file:com.plugin.excel.util.ExcelFileHelper.java
License:Apache License
private static void addNumberValidation(Cell cell) { if (cell != null) { Sheet sheet = cell.getSheet(); DataValidationHelper dvHelper = sheet.getDataValidationHelper(); XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper .createNumericConstraint(ValidationType.DECIMAL, DVConstraint.OperatorType.BETWEEN, "1.00", "1000000000000.00"); CellRangeAddressList addressList = new CellRangeAddressList(cell.getRowIndex(), cell.getRowIndex(), cell.getColumnIndex(), cell.getColumnIndex()); XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList);// w w w . j av a2s.c om validation.setErrorStyle(ErrorStyle.STOP); validation.createErrorBox("Error", "Only numeric values are allowed"); validation.setShowErrorBox(true); sheet.addValidationData(validation); } }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.util.ExcelGeneratorUtils.java
License:Open Source License
/** * Creates a dropdown box for each cell in the specified {@code addressList}. * //w w w . j av a 2 s.co m * @param sheet the sheet to add the dropdown box to * @param addressList the cell range to add the dropdown box to * @param namesListFormula the formula name of the values to be shown in dropdown box */ public static void createDropdown(Sheet sheet, CellRangeAddressList addressList, String namesListFormula) { DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = dataValidationHelper.createFormulaListConstraint(namesListFormula); DataValidation dataValidation = dataValidationHelper.createValidation(dvConstraint, addressList); // There is an error in the interpretation of the argument of setSuppressDropDownArrow in POI 3.9 // for XSSF Workbooks. The arrow is suppressed if the argument is set to 'false' instead of 'true'. // In HSSF Workbooks the method works as designed. // Luckily in both cases the default behavior is, that the arrow is displayed. So we can skip the explicit setting of this behavior. // SKIP THIS: dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.util.ExcelGeneratorUtils.java
License:Open Source License
/** * Creates a dropdown box for each cell in the specified {@code addressList}. * //from w w w .j ava 2 s .co m * @param sheet the sheet to add the dropdown box to * @param addressList the cell range to add the dropdown box to * @param values the values to be shown in dropdown box */ public static void createDropdownWithValues(Sheet sheet, CellRangeAddressList addressList, List<String> values) { DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper(); String[] valuesList = values.toArray(new String[values.size()]); DataValidationConstraint dvConstraint = dataValidationHelper.createExplicitListConstraint(valuesList); DataValidation dataValidation = dataValidationHelper.createValidation(dvConstraint, addressList); // There is an error in the interpretation of the argument of setSuppressDropDownArrow in POI 3.9 // for XSSF Workbooks. The arrow is suppressed if the argument is set to 'false' instead of 'true'. // In HSSF Workbooks the method works as designed. // Luckily in both cases the default behavior is, that the arrow is displayed. So we can skip the explicit setting of this behavior. // SKIP THIS: dataValidation.setSuppressDropDownArrow(false); sheet.addValidationData(dataValidation); }