JXL、POI生成下拉选择框Excel

转自 : http://dead-knight.iteye.com/blog/458395

 

 

JXL生成存在下拉选择框字段的Excel附件代码如下: 

 

 

lLabel = new jxl.write.Label(fieldSize, 0, key, lHeaderCellFormat);  
WritableCellFeatures wcf = new WritableCellFeatures();  
List angerlist = new ArrayList();  
angerlist.add("是");  
angerlist.add("否");  
wcf.setDataValidationList(angerlist);  
lLabel.setCellFeatures(wcf);  
lReadSheet.addCell(lLabel);  

 

 

POI生成存在下拉选择框字段的Excel附件代码如下: 

 

String[] textlist={"业务受理","业务不受理"};  
CellRangeAddressList regions = new CellRangeAddressList(1,rList.size()-1,fieldSize,fieldSize);  
//生成下拉框内容  
DVConstraint constraint = DVConstraint.createExplicitListConstraint(textlist);  
//绑定下拉框和作用区域  
HSSFDataValidation data_validation = new HSSFDataValidation(regions,constraint);    
//对sheet页生效  
sheet.addValidationData(data_validation); 

 

 

POI包下载:http://apache.etoak.com/poi/release/src/

你可能感兴趣的:(java,Excel)