JXL自定义颜色
程序员文章站
2022-07-13 14:28:23
...
BODY { FONT-SIZE: 10pt; FONT-FAMILY: 宋体,sans-serif } TD { FONT-SIZE: 10pt; FONT-FAMILY: 宋体,sans-serif } A { FONT-SIZE: 10pt; FONT-FAMILY: 宋体,sans-serif } P { FONT-SIZE: 10pt; FONT-FAMILY: 宋体,sans-serif } .h { FONT-SIZE: 10pt; FONT-FAMILY: 宋体,sans-serif }
研究了一下JXL对EXCEL 操作的颜色还是可以任意修改的,以后大家生成EXCEL可参照此样式(如附件),
如不合适,统一改一下。
初步分为四部分:
一、题目: 字号: 20
二、标题行:字体:宋体 ,字号: 11 ,背景:蓝
三、内容不可修改行:字体:宋体 红色, 字号:11 , 背景:黄色
四、内容可修改行 :字体:宋体,字号:11 , 背景:浅绿色
workbook = Workbook.createWorkbook(new File(filePath));
workbook.setColourRGB(Colour.BLUE2,0xB3, 0xCB, 0xE2);
workbook.setColourRGB(Colour.YELLOW2,0xFF, 0xFF, 0xAC);
workbook.setColourRGB(Colour.GREEN,0xE6, 0xF7, 0xE1);
// 创建sheet
WritableSheet sheet = workbook.createSheet("test", 0);
//设置字体
// 题目
WritableFont fontNormal= new WritableFont(WritableFont.ARIAL,20);
WritableCellFormat wcfFC = new WritableCellFormat(fontNormal);
// 标题头行
//宋体11号 中间对齐加边框
WritableCellFormat fontSubject = null;
WritableFont timesBold = new WritableFont(WritableFont.createFont("宋体"),11,WritableFont.BOLD,false);
fontSubject = new WritableCellFormat(timesBold);
fontSubject.setAlignment(jxl.format.Alignment.CENTRE);
fontSubject.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
fontSubject.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
fontSubject.setBackground(Colour.BLUE2);
//不可修改内容
WritableCellFormat fontNoContent = null;
WritableFont timesNoThin = new WritableFont(WritableFont.createFont("宋体"),11);
timesNoThin.setColour(Colour.RED); //红色字体
fontNoContent = new WritableCellFormat(timesNoThin);
fontNoContent.setAlignment(jxl.format.Alignment.LEFT);
fontNoContent.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
fontNoContent.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
fontNoContent.setBackground(Colour.YELLOW2); // 黄色背景
//填写内容
WritableCellFormat fontContent = null;
WritableFont timesThin = new WritableFont(WritableFont.createFont("宋体"),11);
fontContent = new WritableCellFormat(timesThin);
fontContent.setAlignment(jxl.format.Alignment.RIGHT);
fontContent.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
fontContent.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
fontContent.setBackground(Colour.GREEN); // 绿色背景
上一篇: 终端自定义颜色
下一篇: xssf 自定义颜色