[prev in list] [next in list] [prev in thread] [next in thread] 

List:       poi-user
Subject:    Named Range not working
From:       jhummer <jack () jahummer ! com>
Date:       2008-12-27 7:07:20
Message-ID: 21182105.post () talk ! nabble ! com
[Download RAW message or body]


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();

-- 
View this message in context: http://www.nabble.com/Named-Range-not-working-tp21182105p21182105.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic