JAVA导出EXCEL

Vector vector=listSparepart(conn, sql,list);//得到LIST
		response.setContentType("application/x-msdownload");
		response.setHeader("content-disposition",
				"attachment; filename=dateexport.xls");
		OutputStream os = response.getOutputStream();
		jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os);
		jxl.write.WritableSheet ws = wwb.createSheet("TestSheet1", 0);
		jxl.write.Label labelC = null;
		for(int i=0;i<vector.size();i++){
			Order order=(Order)vector.get(i);
			labelC = new jxl.write.Label(0, i, order.getSparepart_name());
			ws.addCell(labelC);
			labelC = new jxl.write.Label(1, i, order.getSale_price());
			ws.addCell(labelC);
			labelC = new jxl.write.Label(2, i, order.getCount()+"");
			ws.addCell(labelC);
		}
		wwb.write();
		wwb.close();
		os.close();
		conn.close();

 网上面写得太复杂了我搞个简单的 希望大家能看懂 但是这个不怎么样通用过几天写个通用点的

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