XSSFDataValidationHelper.createDateConstraint有Bug
2015-07-28 19:26
691 查看
注意是:XSSFDataValidationHelper,也即:XSSFDataValidationConstraint(4, operatorType, formula1, formula2)有Bug,HSSF*的没有问题,POI
3.8-POI3.12都试过了,都有此问题
官方不知是否已发现这个Bug,没找到POI论坛发表。
3.8-POI3.12都试过了,都有此问题
/** * 设置ExcelSheet数据填写有效性约束 * @param sheet 当前Sheet * @param validationType 验证类型 * @param operatorType 操作符 * @param rowIndex 行索引 * @param colIndex 列索引 * @param vMin 最小值 * @param vMax 最大值 * @param errorTitle 出错提示标题 * @param errorMsg 出错提示信息 */ public static void setDataValidationCheck(Sheet sheet, int validationType, int operatorType, int rowIndex, int colIndex, String vMin, String vMax, String errorTitle, String errorMsg) { if(null==sheet || rowIndex<0 || colIndex <0) { return; } //两个值都为空则返回 vMin = null == vMin ? "" : vMin.trim(); vMax = null == vMax ? "" : vMax.trim(); if("".equals(vMin) && "".equals(vMax)) { return; } // DataValidationHelper dvHelper = sheet.getDataValidationHelper(); DataValidationConstraint dvConstraint = null; if(validationType == DataValidationConstraint.ValidationType.TEXT_LENGTH) { dvConstraint = dvHelper.createTextLengthConstraint(operatorType, vMin, vMax); } else if(validationType == DataValidationConstraint.ValidationType.DECIMAL) { dvConstraint = dvHelper.createDecimalConstraint(operatorType, vMin, vMax); } else if(validationType == DataValidationConstraint.ValidationType.INTEGER) { dvConstraint = dvHelper.createIntegerConstraint(operatorType, vMin, vMax); } else if(validationType == DataValidationConstraint.ValidationType.DATE) { dvConstraint = dvHelper.createDateConstraint(operatorType, vMin, vMax, null); } else if(validationType == DataValidationConstraint.ValidationType.TIME) { dvConstraint = dvHelper.createTimeConstraint(operatorType, vMin, vMax); } if(null == dvConstraint) { return; } CellRangeAddressList addressList = new CellRangeAddressList(rowIndex, getLastRowIndex(sheet.getWorkbook()), colIndex, colIndex); DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); //设置出错提示信息 validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true); setDataValidationErrorMessage(validation, errorTitle, errorMsg); sheet.addValidationData(validation); }
官方不知是否已发现这个Bug,没找到POI论坛发表。
相关文章推荐
- Sinatra:一个可以作为Rails有益补充的框架. 简洁而不简单
- 15/7/27/正则表达式/进程线程/wait/notify
- 语言中如何在main函数开始前执行函数
- HDU 5319 Painter (模拟 脑洞题)
- 2015 Multi-University Training Contest 3
- Acboy needs your help again!
- Failed to install *.apk on device 'emulator-5554': timeout
- 2015 Multi-University Training Contest 3(hdu 5316、5317、5319、5323、5325、5326)线段树+数学+yy+矩阵快速幂
- 2015 Multi-University Training Contest 3
- Aizu 0009 Prime Number
- this,static,main参数作用,方法,对象的生存
- Rails Model验证之强大
- Kafka设计解析(三):Kafka High Availability (下)
- HDU2124——Repair the Wall(贪心水题)
- Kafka设计解析(二):Kafka High Availability (上)
- [Poj3523][Uva1601][Aizu1281] The Morning after Halloween 【A*算法】
- Aizu 0005 GCD and LCM
- 一次AIX系统报错的问题处理思路
- Ubuntu 下 su:authentication failure的解决办法
- LeetCode 11 -- Container With Most Water