Unable display comma value in cell content using data validation with explicit list constraint using poi

梦想的初衷 提交于 2019-12-11 15:26:14

问题


I am using Apache POI (v 3.8) for adding drop down list for cell with data validation.But comma(,) value is separated to another value in list.Other than comma (,) its working fine and check below screen shot

Code

DataValidation dataValidation = null;
DataValidationConstraint constraint = null;
DataValidationHelper validationHelper = null;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet1=(XSSFSheet) wb.createSheet("sheet1");

validationHelper=new XSSFDataValidationHelper(sheet1);
CellRangeAddressList addressList = new  CellRangeAddressList(1,10,1,1);
constraint =validationHelper.createExplicitListConstraint(new String[]{"SELECT","A,B", "C%D","B$D", "C&D","A( A & B)"});
dataValidation = validationHelper.createValidation(constraint, addressList);
dataValidation.setSuppressDropDownArrow(true);      
sheet1.addValidationData(dataValidation);
FileOutputStream fileOut;
        try {
            fileOut = new FileOutputStream("f:\\test-1.xlsx");
              wb.write(fileOut);
                fileOut.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

I tried to replace with ASCII code.But appended ascii code value instead of comma(,).Please help on this

来源:https://stackoverflow.com/questions/46438808/unable-display-comma-value-in-cell-content-using-data-validation-with-explicit-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!