poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44773] Combo box in excel sheet
Date Thu, 10 Apr 2008 08:27:14 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=44773


Josh Micich <josh@gildedtree.com> changed:

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




--- Comment #1 from Josh Micich <josh@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


Mime
View raw message