JXL Excel模版下载[列合并](2)
来源:互联网 发布:ansys15.0软件 编辑:程序博客网 时间:2024/06/07 16:47
效果图:
代码:
public void exportTemplateProceeds(HttpServletResponse response) { // TODO Auto-generated method stub WritableWorkbook workbook = null; try { try{ OutputStream outPutS = response.getOutputStream(); response.resetBuffer(); String outFileName=new String("合同收款明细补录模版".getBytes("gb2312"),"ISO8859-1") + ".xls"; response.setHeader("Content-disposition","attachment;filename="+outFileName); response.setContentType("application/excel"); workbook = Workbook.createWorkbook(outPutS); WritableSheet sheet = workbook.createSheet("sheet1", 0); String title[] = { "还款日期|15", "设备成本|15", "租赁费|15", "应收租金|15", "实收租金|15", "支付日期|15", "逾期天数|15", "利息|15", "罚金|15", "调息差|14", "支付日期|14", "备注|20", "收款合计|15" }; Label label = null; /** 字体设置 */ WritableFont headerFont = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); WritableFont headerFont1 = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.RED); WritableCellFormat headerFormat1 = new WritableCellFormat(headerFont); headerFormat1.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.BLACK); headerFormat1.setAlignment(Alignment.LEFT); headerFormat1.setBackground(Colour.YELLOW); WritableCellFormat headerFormat = new WritableCellFormat(headerFont1); headerFormat.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.BLACK); headerFormat.setAlignment(Alignment.RIGHT); headerFormat.setBackground(Colour.YELLOW); /** 格式 */ WritableCellFormat colFormat = new WritableCellFormat(headerFont); colFormat.setAlignment(Alignment.LEFT); colFormat.setWrap(true); WritableFont titleFont = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); WritableCellFormat titleFormat = new WritableCellFormat(titleFont); titleFormat.setAlignment(Alignment.CENTRE); label = new Label(0,0,"注意:表中是最新数据",headerFormat1); sheet.addCell(label); sheet.mergeCells(0,0, title.length-1,0); //合并单元格 WritableCellFormat wc = new WritableCellFormat(headerFont); // 设置居中 wc.setAlignment(Alignment.CENTRE); // 设置边框线 wc.setBorder(Border.ALL, BorderLineStyle.THIN); // 设置单元格的背景颜色 wc.setBackground(jxl.format.Colour.GRAY_25); //(列1,行,从列1到?,第几行) sheet.mergeCells(1, 1, 3, 1); label = new Label(1, 1, "租金",wc); sheet.addCell(label); sheet.mergeCells(4, 1, 6, 1); label = new Label(4, 1, "租金项目收款",wc); sheet.addCell(label); sheet.mergeCells(7, 1, title.length-2, 1); label = new Label(7, 1, "其他应收项目",wc); sheet.addCell(label); int col = 0; for (int i = 0; i < title.length; i++) { String[] arrayTitle = title[i].split("\\|"); label = new Label(col, 2, arrayTitle[0],titleFormat); sheet.addCell(label); // 设置列宽 sheet.setColumnView(col, Integer.parseInt(arrayTitle[1])); col++; } workbook.write(); workbook.close(); }catch(Exception e1){ if(workbook!=null){ workbook.close(); } } } catch (Exception e) { e.printStackTrace(); } }
0 0
- JXL Excel模版下载[列合并](2)
- JXL Excel模版模版下载(1)
- jxl操作excel 字体 背景色 合并单元格 列宽
- jxl 设置excel 字体 背景色 合并单元格 列宽
- jxl操作excel 字体 背景色 合并单元格 列宽
- jxl 设置excel 字体 背景色 合并单元格 列宽
- jxl 设置excel 字体 背景色 合并单元格 列宽
- jxl excel分组合并
- jxl调用模版导出Excel
- jxl合并单元格导出excel
- jxl 合并EXCEL 报错
- jxl操作excel 字体 背景色 合并单元格 列宽等
- jxl操作excel 字体 背景色 合并单元格 列宽等
- jxl 设置excel 字体 背景色 合并单元格 列宽 等
- java jsp JXL调用模版导出Excel
- java jsp JXL调用模版导出Excel
- jxl生成excel并下载
- jsp使用jxl下载excel
- LeetCode203:Remove Linked List Elements
- Java Synchronized与wait notify 连用-2 简化版
- Baidu Map API 学习历程
- POST请求
- 通过代码实现RelativeLayout的布局
- JXL Excel模版下载[列合并](2)
- apache相关配置问题
- 【模板整合】SAM后缀自动机的构建
- Android Exception : JAVA_HOME is set to an invalid directory
- 使用fiddler的断点调试抓包修改请求和响应
- 期望和方差
- [LeetCode] Product of Array Except Self
- 小白学Python(二) 基本文件操作
- Android开发学习笔记之Activity属性设置