jxls在excel中创建下拉菜单

/**
 * 利用jxls在excel中创建下拉菜单
 * @param sheet 
 * @param y  要创建下拉菜单的行号(以0开始计数)
 * @param x  要创建下拉菜单的列号(以0开始计数)
 * @return
*/
public void createListBox (Sheet sheet,int y,int x){
		//生成下拉列表
		CellRangeAddressList regions = new CellRangeAddressList(y,y,x,x);//CellRangeAddressList(int firstRow,int lastRow,int firstCol,int lastCol);
		//生成下拉框内容
		DVConstraint constraint = DVConstraint.createExplicitListConstraint(new String[]{"Yes","No"});
		//添加下拉菜单到sheet
		HSSFDataValidation data_validation = new HSSFDataValidation(regions,constraint);
		sheet.addValidationData(data_validation);
	}


参见:
http://wenku.baidu.com/view/3a44ac48c850ad02de8041e2.html
http://www.cnblogs.com/linzheng/archive/2010/12/20/1912173.html
http://blog.csdn.net/wed840313/article/details/7546134

你可能感兴趣的:(Excel)