java - POI Named Cell - Drop down in all the rows does not have all the values -


i have strange issue when create excel drop downs using apache poi - named cell using below method.

public static void createhugedropdown(xssfworkbook wb) {         int = 0;         string sheetname = "lookup";         string colname = "col1";         string mainsheet = "sheet1";         string[] strarray = new string[]{"10", "20", "30"};         xssfsheet sheet = wb.createsheet(sheetname);         (string str : strarray) {             sheet.createrow(i++).createcell(0).setcellvalue(str);         }          xssfname namedcell = wb.createname();         namedcell.setnamename(colname);         string reference = sheetname + "!a1:a" + i;         system.out.println(reference);         namedcell.setreferstoformula(reference);          xssfsheet sheet1 = wb.getsheet(mainsheet);         int namedcellindex = wb.getnameindex(colname);         namedcell = wb.getnameat(namedcellindex);         areareference aref = new areareference(namedcell.getreferstoformula());         cellreference[] crefs = aref.getallreferencedcells();         system.out.println("total count --> " + crefs.length);         (int count = 0; count < crefs.length; count++) {             sheet s = wb.getsheet(crefs[count].getsheetname());             row r = sheet.getrow(crefs[count].getrow());             cell c = r.getcell(crefs[count].getcol());             system.out.println("cell value" + c.getstringcellvalue());         }          datavalidationconstraint constraint = null;         datavalidation datavalidation = null;         cellrangeaddresslist addresslist = new cellrangeaddresslist(0, 100, 2, 2);         datavalidationhelper validationhelper = new xssfdatavalidationhelper(sheet1);         system.out.println(reference);          constraint = validationhelper.createformulalistconstraint(reference);         datavalidation = validationhelper.createvalidation(constraint, addresslist);         datavalidation.setsuppressdropdownarrow(true);         wb.getsheet(mainsheet).addvalidationdata(datavalidation);     } 

this creates me drop down. issue 1) have 10,20 & 30 in first row 2) have 20 & 30 alone in second row 3) have 30 alone in third row. 4) empty drop down fourth row till 100th row.

can point me issue in above code.

i want display 3 values in drop down in rows.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -