After some more testing, it seems there were two problems. First, both 3.2 and 3.5beta4 appear to have an issue with a named range that is exactly one cell (since I was using the range for a validation, my work-around was to substitute with an Explicit list). Second, 3.5beta4 seemed to have a general problem defining a named range; I will try the newer build for that issue.
Yegor Kozlov wrote: > > I can't reproduce the problem with the latest sources (but confirmed it > with 3.5beta4). > Can you check against the latest trunk? Daily builds can be downloaded > from http://encore.torchbox.com/poi-svn-build/. > > I think the problem was fixed in r723392 on Dec 4. HSSFName set incorrect > type of the underlying formula tokens, as > result, created names didn't appear in the drop-down to the left of > formula bar in Excel. I think it also affected Data > Validation. > > Yegor > >> Using 3.5beta4 the code below builds one cell with a Validation. When >> you >> open the spreadsheet (WinXP, Excel 2003), the drop-down has no value. If >> you do Data / Validation the dialog looks good, but if you click OK it >> gives >> an error. Now, close that and do Insert / Name / Define then click on >> the >> range name, click into the Refers To field, then OK. The drop-down now >> works correctly. It appears Excel re-wrote the Name and fixed some >> format >> error.....unless there is another explanation. >> >> Also, if someone has an answer, can you tell CellRangeAddressList you >> want >> an entire column, e.g. "A:A" in excel? Thanks. >> >> HSSFWorkbook wBook = new HSSFWorkbook(); >> HSSFSheet mySheet = wBook.createSheet("Values"); >> HSSFRow myRow = mySheet.createRow((short) 0); >> myRow.createCell(0); >> myRow.createCell(1).setCellValue("A valid value"); >> HSSFName rName = wBook.createName(); >> rName.setNameName("RegType"); >> rName.setRefersToFormula("Values!$B$1"); >> DVConstraint myDVC = DVConstraint.createFormulaListConstraint("RegType"); >> CellRangeAddressList myCRAL = new CellRangeAddressList(0, 0, 0, 0); >> HSSFDataValidation myDV = new HSSFDataValidation(myCRAL, myDVC); >> mySheet.addValidationData(myDV); >> FileOutputStream fOut = new FileOutputStream("range.xls"); >> wBook.write(fOut); >> fOut.close(); >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > -- View this message in context: http://www.nabble.com/Named-Range-not-working-tp21182105p21338031.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
