/*****/Package test. excel;/*** @ author seven * 09:15:23 */import Java. io. fileoutputstream; import Java. util. date; import Org. apache. poi. hssf. usermodel. dvconstraint; import Org. apache. poi. hssf. usermodel. hssfcell; import Org. apache. poi. hssf. usermodel. hssfdatavalidation; import Org. apache. poi. hssf. usermodel. hssfrow; import Org. apache. poi. hssf. usermodel. hssfsheet; import Org. apache. poi. hssf. usermodel. hssfworkbook; import Org. apache. poi. hssf. util. cellrangeaddresslist; public class poi {public static void main (string [] ARGs) {string [] list = {"Neusoft", "Huaxin", "sap", "Hai Hui "}; new poi (). createlistbox (list); return;} public void createlistbox (string [] list) {// file initialization hssfworkbook WB = new hssfworkbook (); hssfsheet sheet = WB. createsheet ("new sheet"); // insert hssfrow ROW = sheet in the first cell of the first row. createrow (0); hssfcell cell = row. createcell (0); // cell for normal write operations. setcellvalue ("select"); // This is an experiment // generate a drop-down list // only valid for cells () cellrangeaddresslist regions = new cellrangeaddresslist (0, 0, 0, 0, 0); // generate the content dvconstraint constraint = dvconstraint in the drop-down box. createexplicitlistconstraint (list); // bind the drop-down box and hssfdatavalidation data_validation = new hssfdatavalidation (regions, constraint); // apply sheet to the sheet page. addvalidationdata (data_validation); // write fileoutputstream fileout; try {fileout = new fileoutputstream ("workbook.xls"); WB. write (fileout); fileout. close ();} catch (exception e) {// todo auto-generated catch blocke. printstacktrace ();} // end system. out. println ("over ");}}