我正在尝试创建一个 dataValidation 对象,其中 List Constraint 是一个范围单个连续列的名称...。我将作为参数传递给 createFormulaListConstraint() 的列表与我想要的工作表不同显示数据验证。以下是我到目前为止的代码,当我尝试运行它时,会抛出一个FormulaParseException: Specified name range does not exist in the current workbook:
Name name = dctmWorkSheet.getWorkbook().createName();
name.setSheetIndex(1);
name.setNameName(cell.getStringCellValue());
name.setRefersToFormula(getRangeRefersToFormula(valueAssSheet, firstRow, rowIndex, insertCol));
validationHelper = dctmWorkSheet.getDataValidationHelper();
//------ THIS IS THE LINE RESPONSIBLE FOR THE EXCEPTION -------
constraint = validationHelper.createFormulaListConstraint(name.getNameName());
dataValidation = validationHelper.createValidation(constraint, cral);
dataValidation.setEmptyCellAllowed(true);
dataValidation.setShowErrorBox(true);
dataValidation.setErrorStyle(DataValidation.ErrorStyle.STOP);
dataValidation.createErrorBox("Error", "Please use Pick List Value");
dctmWorkSheet.addValidationData(dataValidation);
感谢您的任何帮助或反馈......