Java通过JXL操作excel
程序员文章站
2024-02-24 13:11:05
...
生成具有选择框的excel,可以选是或者否如下所示:
是 | www.someabcd.com大杂烩 |
代码如下:
public static void main(String[] args) {
try {
WritableWorkbook book = Workbook.createWorkbook(new File("test.xls"));
WritableSheet sheet = book.createSheet("第一页", 0);
List<String> angerlist = new ArrayList<String>();
angerlist.add("是");
angerlist.add("否");
Label norFormat = new Label(0,0, "是");
WritableCellFeatures ws = new WritableCellFeatures();
ws.setDataValidationList(angerlist);
norFormat.setCellFeatures(ws);
sheet.addCell(norFormat);
Label norFormat2 = new Label(1,0, "www.someabcd.com大杂烩");
sheet.addCell(norFormat2);
book.write();
book.close();
} catch (Exception e) {
System.out.println(e);
}
}
注意情况:
jxl对03以下支持灰常好,对于07的下拉框支持的不好建议用poi操作