https://bz.apache.org/bugzilla/show_bug.cgi?id=66166

tao li <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from tao li <[email protected]> ---

    private static DataValidation createCustomValidation(Sheet sheet, String
formula, String info, int col, int maxRow, int lastRow) {
        String msg = "请输入正确的值!";
        Workbook workbook = sheet.getWorkbook();
                if (workbook instanceof HSSFWorkbook) {
                        // 0.XLS格式公式定位问题不处理,  默认从当前单元格A开始计算, 只能向后引用目前发现,
属于POI的BUG
                        formula = formula.replace("=", "");
        }
        // 1.设置验证
        CellRangeAddressList cellRangeAddressList = new
CellRangeAddressList(maxRow, lastRow, col, col);
        DataValidationHelper helper = sheet.getDataValidationHelper();
        DataValidationConstraint constraint =
helper.createCustomConstraint(formula);
        DataValidation dataValidation = helper.createValidation(constraint,
cellRangeAddressList);

        // 处理Excel兼容性问题
        if (dataValidation instanceof XSSFDataValidation) {
            dataValidation.setSuppressDropDownArrow(true);
            dataValidation.setShowErrorBox(true);
        } else {
            dataValidation.setSuppressDropDownArrow(false);
        }
        dataValidation.setEmptyCellAllowed(true);
        dataValidation.setShowPromptBox(true);
        if (info != null) {
            msg = info;
        }
        dataValidation.createPromptBox("提示", msg);
        return dataValidation;
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to