You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2022/07/08 01:11:38 UTC

[Bug 66166] New: the data validation area of the cell is incorrect

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

            Bug ID: 66166
           Summary: the data validation area of the cell is incorrect
           Product: POI
           Version: 5.2.2-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: 353613274@qq.com
  Target Milestone: ---

In the hssfworkbook, the createcustomconstraint method of datavalidationhelper
is used to create custom formula validation. After excel production, it is
opened and found that the data validation area of the cell is incorrect

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 66166] the data validation area of the cell is incorrect

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66166

tao li <35...@qq.com> changed:

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

--- Comment #1 from tao li <35...@qq.com> ---

    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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org