c# - why NPOI created cell drop down list always split by comma -
i use npoi(the .net version of java - apache poi) created excel sheet. need add dropdown, found no matter list passed it, split item value comma, make new line. in chance, know how avoid happen? here code
cellrangeaddresslist cellrange = new cellrangeaddresslist(cell.rowindex, cell.rowindex, cell.columnindex, cell.columnindex); dvconstraint constraint = dvconstraint.createexplicitlistconstraint(new string[] {"$400","$1,900"}); hssfdatavalidation validation = new hssfdatavalidation(cellrange, constraint); validation.suppressdropdownarrow = false; sheet.addvalidationdata(validation);
while passing values constraint pass values without comma , $ sign
dvconstraint constraint = dvconstraint.createexplicitlistconstraint(new string[]{"400","1900"});
and below formatting approach take care of appearance of value in dropdown
xssfcellstyle yourcellstyle = (xssfcellstyle)workbook.createcellstyle(); xssfdataformat yourdataformat = (xssfdataformat)workbook.createdataformat(); yourcellstyle.setdataformat(yourdataformat.getformat("$#,###.00")); sheet.setdefaultcolumnstyle(col, yourcellstyle);
Comments
Post a Comment