|
public static void write(String filePath) throws IOException, ClassNotFoundException {
//初始一个workbook
HSSFWorkbook workbook = new HSSFWorkbook();
//创建一个sheet
HSSFSheet sheet = workbook.createSheet("Test Select");
//准备下拉列表数据
String[] strs = new String[]{"111", "222", "333", "444", "555", "666", "777", "888", "999"};
//设置第一列的1-10行为下拉列表
CellRangeAddressList regions = new CellRangeAddressList(0, 9, 0, 0);
//创建下拉列表数据
DVConstraint constraint = DVConstraint.createExplicitListConstraint(strs);
//绑定
HSSFDataValidation dataValidation = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(dataValidation);
FileOutputStream stream = new FileOutputStream(filePath);
workbook.write(stream);
stream.close();
}
http://blog.csdn.net/scholar_man/article/details/48177833
XSSF下拉框:http://blog.csdn.net/u014792342/article/details/47973087
http://blog.csdn.net/enshiwaer/article/details/53466431?locationNum=13&fps=1
|