- package com.test;
- import java.io.FileOutputStream;
import java.io.OutputStream; -
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
public class jx {- public static void main(String[] args) {
try {
// 创建可写入的Excel工作薄
OutputStream os = new FileOutputStream("D://数据汇总分析表.xls");
WritableWorkbook workbook1 = Workbook.createWorkbook(os); - WritableSheet sheet = workbook1.createSheet("数据汇总分析表", 0);
- // 设置保护
sheet.getSettings().setProtected(false);
// 设置锁定第一列
sheet.getSettings().setHorizontalFreeze(1);
// 设置锁定4行
sheet.getSettings().setVerticalFreeze(7);
// 设置单元格宽度 - // (1=5.25cm)
//sheet.setColumnView(0,0);
// (1=0.05cm)
// sheet.setRowView(0,0); - WritableFont wf = new jxl.write.WritableFont(WritableFont
.createFont("黑体"), 12, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.BLUE); - WritableCellFormat wcf = new WritableCellFormat(wf);
- // 设置背景颜色
//wcf.setBackground(Colour.RED);
// 设置文字横向显示位置
wcf.setAlignment(Alignment.CENTRE);
// 设置文字纵向显示位置
wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
// 设置边框
wcf.setBorder(Border.ALL, BorderLineStyle.THIN);
// 设置自动换行
wcf.setWrap(true);
- sheet.mergeCells(0, 1, 0, 3);
Label label = new Label(0, 1, null, wcf);
sheet.addCell(label);
- sheet.mergeCells(1, 1, 15, 1);//sheet.mergeCells(所在列数(1表示第2列), 所占行数, 所占列数, 1)
label = new Label(1, 1, "个人业务保费收入", wcf);
sheet.addCell(label); -
sheet.mergeCells(1, 2, 11, 2);
label = new Label(1, 2, "新契约期末有效保费", wcf);
sheet.addCell(label); -
sheet.mergeCells(12, 2, 13, 3);
label = new Label(12, 2, "续期保费", wcf);
sheet.addCell(label);
sheet.mergeCells(14, 2, 15, 3);
label = new Label(14, 2, "合计", wcf);
sheet.addCell(label); - sheet.mergeCells(1, 3, 2, 3);
label = new Label(1, 3, "期缴", wcf);
sheet.addCell(label); - sheet.mergeCells(3, 3, 4, 3);
label = new Label(3, 3, "趸缴", wcf);
sheet.addCell(label); - sheet.mergeCells(5, 3, 11, 3);
label = new Label(5, 3, "小计", wcf);
sheet.addCell(label); - sheet.mergeCells(0, 4, 0, 6);
label = new Label(0, 4, null, wcf);
sheet.addCell(label); - sheet.mergeCells(1, 4, 1, 6);
label = new Label(1, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(2, 4, 2, 6);
label = new Label(2, 4, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(3, 4, 3, 6);
label = new Label(3, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(4, 4, 4, 6);
label = new Label(4, 4, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(5, 4, 10, 4);
label = new Label(5, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(11, 4, 11, 6);
label = new Label(11, 4, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(5, 5, 5, 6);
label = new Label(5, 5, "总保费", wcf);
sheet.addCell(label); - sheet.mergeCells(6, 5, 8, 5);
label = new Label(6, 5, "寿险", wcf);
sheet.addCell(label); - label = new Label(6, 6, "传统险", wcf);
sheet.addCell(label); - label = new Label(7, 6, "分红险", wcf);
sheet.addCell(label); - label = new Label(8, 6, "万能险", wcf);
sheet.addCell(label); - sheet.mergeCells(9, 5, 9, 6);
label = new Label(9, 5, "健康险", wcf);
sheet.addCell(label); - sheet.mergeCells(10, 5, 10, 6);
label = new Label(10, 5, "意外险", wcf);
sheet.addCell(label); - sheet.mergeCells(12, 4, 12, 6);
label = new Label(12, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(13, 4, 13, 6);
label = new Label(13, 4, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(14, 4, 14, 6);
label = new Label(14, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(15, 4, 15, 6);
label = new Label(15, 4, "累计", wcf);
sheet.addCell(label); - // 团险
sheet.mergeCells(16, 1, 25, 3);
label = new Label(16, 1, "团体业务保费收入", wcf);
sheet.addCell(label); - sheet.mergeCells(16, 4, 24, 4);
label = new Label(16, 4, null, wcf);
sheet.addCell(label); - sheet.mergeCells(25, 4, 25, 6);
label = new Label(25, 4, "累计", wcf);
sheet.addCell(label); - label = new Label(16, 5, "总保费", wcf);
sheet.addCell(label); - label = new Label(16, 6, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(17, 5, 18, 5);
label = new Label(17, 5, "年金", wcf);
sheet.addCell(label); - label = new Label(17, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(18, 6, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(19, 5, 20, 5);
label = new Label(19, 5, "健康", wcf);
sheet.addCell(label); - label = new Label(19, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(20, 6, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(21, 5, 22, 5);
label = new Label(21, 5, "寿险", wcf);
sheet.addCell(label); - label = new Label(21, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(22, 6, "累计", wcf);
sheet.addCell(label); - sheet.mergeCells(23, 5, 24, 5);
label = new Label(23, 5, "意外险", wcf);
sheet.addCell(label); - label = new Label(23, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(24, 6, "累计", wcf);
sheet.addCell(label); - // 银行代理业务保费收入
sheet.mergeCells(26, 1, 31, 3);
label = new Label(26, 1, "银行代理业务保费收入", wcf);
sheet.addCell(label); - sheet.mergeCells(26, 4, 27, 4);
label = new Label(26, 4, "期缴", wcf);
sheet.addCell(label); - sheet.mergeCells(28, 4, 29, 4);
label = new Label(28, 4, "趸缴", wcf);
sheet.addCell(label); - sheet.mergeCells(30, 4, 31, 4);
label = new Label(30, 4, "合计", wcf);
sheet.addCell(label); - sheet.mergeCells(26, 5, 27, 5);
label = new Label(26, 5, null, wcf);
sheet.addCell(label); - sheet.mergeCells(28, 5, 29, 5);
label = new Label(28, 5, null, wcf);
sheet.addCell(label); - sheet.mergeCells(30, 5, 31, 5);
label = new Label(30, 5, null, wcf);
sheet.addCell(label); - label = new Label(26, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(27, 6, "累计", wcf);
sheet.addCell(label); - label = new Label(28, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(29, 6, "累计", wcf);
sheet.addCell(label); - label = new Label(30, 6, "本期", wcf);
sheet.addCell(label); - label = new Label(31, 6, "累计", wcf);
sheet.addCell(label); - // 其他
sheet.mergeCells(32, 1, 33, 3);
label = new Label(32, 1, "其他", wcf);
sheet.addCell(label); - sheet.mergeCells(32, 4, 32, 6);
label = new Label(32, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(33, 4, 33, 6);
label = new Label(33, 4, "累计", wcf);
sheet.addCell(label); - // 保费收入总计
sheet.mergeCells(34, 1, 35, 3);
label = new Label(34, 1, "保费收入总计", wcf);
sheet.addCell(label); - sheet.mergeCells(34, 4, 34, 6);
label = new Label(34, 4, "本期", wcf);
sheet.addCell(label); - sheet.mergeCells(35, 4, 35, 6);
label = new Label(35, 4, "累计", wcf);
sheet.addCell(label); - // 营销员规模人力
sheet.mergeCells(36, 1, 39, 3);
label = new Label(36, 1, "营销员规模人力", wcf);
sheet.addCell(label); - sheet.mergeCells(36, 4, 36, 6);
label = new Label(36, 4, "上月规模人力", wcf);
sheet.addCell(label); - sheet.mergeCells(37, 4, 37, 6);
label = new Label(37, 4, "本月新增人数", wcf);
sheet.addCell(label); - sheet.mergeCells(38, 4, 38, 6);
label = new Label(38, 4, "本月脱落人数", wcf);
sheet.addCell(label); - sheet.mergeCells(39, 4, 39, 6);
label = new Label(39, 4, "本月规模人力", wcf);
sheet.addCell(label); - // 团险外勤人数
sheet.mergeCells(40, 1, 40, 6);
label = new Label(40, 1, "团险外勤人数", wcf);
sheet.addCell(label); - // 银行保险外勤人数
sheet.mergeCells(41, 1, 41, 6);
label = new Label(41, 1, "银行保险外勤人数", wcf);
sheet.addCell(label); - // 银行网点数
sheet.mergeCells(42, 1, 42, 6);
label = new Label(42, 1, "银行网点数", wcf);
sheet.addCell(label); - workbook1.write();
workbook1.close(); - } catch (Exception e) {
e.printStackTrace(); - }
- }
- }
用jx实现excel报表
最新推荐文章于 2023-09-21 09:56:24 发布