我正在嘗試使用Apche-poi-3.9在XLS中創建下拉列表。 下面的代碼我寫::apche-poi-3.9 +創建下拉列表
public class TestMacroTemplate {
/**
* @param args
* @throws IOException
*/
public static void main(String args[]) throws FileNotFoundException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Data Validation");
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
DVConstraint dvConstraint = DVConstraint
.createExplicitListConstraint(new String[] { "10", "20", "30" });
DataValidation dataValidation = new HSSFDataValidation(addressList,
dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
sheet.addValidationData(dataValidation);
FileOutputStream fileOut = new FileOutputStream("XLCellDropDown.xls");
try {
workbook.write(fileOut);
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
但它提供了以下異常:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.addValidationData(Lorg/apache/poi/ss/usermodel/DataValidation;)V
at ejb.TestMacroTemplate.main(TestMacroTemplate.java:31)
而同樣的代碼使用Apache的POI-3.2
請幫助我。
感謝, Nirav