欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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操作