You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2008/04/10 10:27:14 UTC

DO NOT REPLY [Bug 44773] Combo box in excel sheet

https://issues.apache.org/bugzilla/show_bug.cgi?id=44773


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Josh Micich <jo...@gildedtree.com>  2008-04-10 01:27:14 PST ---
One way is through Excel 'Data Validations' (I am not sure if there are any
better ways.)

Here is some quick code I hacked out of an existing test case:

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");

short rowIx = 0;
short colIx = 0;
HSSFDataValidation data_validation = new HSSFDataValidation(rowIx, colIx,rowIx,
colIx);
data_validation.setDataValidationType(HSSFDataValidation.DATA_TYPE_LIST);
data_validation.setFirstFormula("$A$20:$A$29");
data_validation.setSecondFormula(null);
data_validation.setSurppressDropDownArrow(false);
data_validation.setShowPromptBox(false);
data_validation.setShowErrorBox(false);
sheet.addValidationData(data_validation);

for (int i=0; i<10; i++) {
   HSSFRow currRow = sheet.createRow(i+19);
   currRow.createCell((short)0).setCellValue(new HSSFRichTextString("val " +
i));
}

File fOut = new File("c:/josh/temp/dfEx-out.xls");
try {
        FileOutputStream os = new FileOutputStream(fOut);
        wb.write(os);
        os.close();
} catch (IOException e) {
        throw new RuntimeException(e);
}


You probably want to do something a little different to this, but it should be
a good start.  It would be helpful to know how to manipulate Data Validations
manually through the Excel GUI.  That will make it easier to anticipate how
things might be modeled in POI.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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