POI--各种样式的XSSFCellStyle的生成
//背景色、フォント色、枠線より各種XSSFCellStyleの作成して、cellStyleMapに保存する
private HashMap<String, XSSFCellStyle> createXssfCellStyle() {
HashMap<String, XSSFCellStyle> cellStyleMap = new HashMap<>(); XSSFCellStyle xssfCellStyle;
String mapKey = "";
XSSFColor[] xssfColorArr = new XSSFColor[bgColorArr.length];
XSSFFont[] xssfFontArr = new XSSFFont[fontColorArr.length];
for(int bgColorIndex=0; bgColorIndex<bgColorArr.length; bgColorIndex++) {
xssfColorArr[bgColorIndex] = createXssfColor(bgColorArr[bgColorIndex]);
}
for(int fontColorIndex=0; fontColorIndex<fontColorArr.length; fontColorIndex++) {
xssfFontArr[fontColorIndex] = createXssfFont(fontColorArr[fontColorIndex]);
} for (int bgColorIndex=0; bgColorIndex<bgColorArr.length; bgColorIndex++) {
for(int fontColorIndex=0; fontColorIndex<fontColorArr.length; fontColorIndex++) {
for(int rightBorderNameIndex=0; rightBorderNameIndex<borderNameArr.length; rightBorderNameIndex++ ) {
for (int bottomBorderNameIndex=0; bottomBorderNameIndex<borderNameArr.length; bottomBorderNameIndex++ ) {
for (int dataFormatIndex=0; dataFormatIndex<dataFormatArr.length; dataFormatIndex++) {
for (int wrapTextIndex=0; wrapTextIndex < wrapTextArr.length; wrapTextIndex++) {
xssfCellStyle = wb.createCellStyle();
xssfCellStyle.setFillForegroundColor(xssfColorArr[bgColorIndex]);
xssfCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
xssfCellStyle.setFont(xssfFontArr[fontColorIndex]);
xssfCellStyle.setBorderTop(BorderStyle.HAIR);
xssfCellStyle.setBorderLeft(BorderStyle.HAIR);
xssfCellStyle.setBorderRight(BorderStyle.valueOf(borderNameArr[rightBorderNameIndex]));
xssfCellStyle.setBorderBottom(BorderStyle.valueOf(borderNameArr[bottomBorderNameIndex]));
xssfCellStyle.setDataFormat(dataFormatArr[dataFormatIndex]);
xssfCellStyle.setWrapText(wrapTextArr[wrapTextIndex]); //right border name(MEDIUMやHAIR) + bottom border name(MEDIUMやHAIR) + font color(000000など) + background color (ffffffなど)
mapKey = borderNameArr[rightBorderNameIndex]
+ borderNameArr[bottomBorderNameIndex]
+ fontColorArr[fontColorIndex]
+ bgColorArr[bgColorIndex]
+ dataFormatArr[dataFormatIndex]
+ wrapTextKeyArr[wrapTextIndex];
cellStyleMap.put(mapKey, xssfCellStyle);
} } }
}
}
}
return cellStyleMap;
} //右枠線のNAME、下枠線のNAME、フォント色、背景色より、合っているXSSFCellStyleを取得
private XSSFCellStyle getXssfCellStyle(String rightBorderName, String bottomBorderName, String fontColor, String bgColor, int dataFormat, boolean isWrapped ) {
String wrapTextKey = WRAP_TEXT_KEY_FALSE;
if (isWrapped) {
wrapTextKey = WRAP_TEXT_KEY_TRUE;
}
String mapKey = rightBorderName + bottomBorderName + fontColor + bgColor + dataFormat + wrapTextKey;
if (!xssfCellStyleMap.containsKey(mapKey)) {
}
return xssfCellStyleMap.get(mapKey);
}
POI--各种样式的XSSFCellStyle的生成的更多相关文章
- ExcelHelper----根据指定样式的数据,生成excel(一个sheet1页)文件流
/// <summary> /// Excel导出类 /// </summary> public class ExcelHelper { /// <summary> ...
- JAVA POI 应用系列(1)--生成Excel
POI简介(官网:http://poi.apache.org/) Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office ...
- poi操作excel2007(读取、生成、编辑)
因为现在再写excel2003版的比较low,所以我在这就不介绍了,直接介绍2007,我所用的编程软件是IDEA poi操作office总共有6个jar包,在pom.xml文件中配置如下,也可下载后直 ...
- 漂亮的CSS按钮样式集以及在线生成工具
以前我们制作一样带带阴影.圆角或3D感的按钮都需要用图片来制作,但CSS3出来后就可以不用图片了,由于是代码写的按钮样式,在Retina上浏览依然清晰美观.虽然不错,但我们写一个阴影+质感的按钮还是挺 ...
- iText、poi操作word2007(读取,生成)
关于生成word文件以及插入文字.表格.图片等功能,我使用了poi和itext,因为poi插入图片的jar包我在网上查并不是太完全,也可能我没找到如何使用,所以插入图片我用的是itext iText所 ...
- POI格式化Cell样式
通过一个实例演示怎样通过POI设置Excel单元格的边框.字体.颜色.大小.下划线.合并.对齐方式. Excel文件如下: Java代码 package my.excel; impor ...
- POI简易帮助文档系列--给Excel设置样式
正如Html需要CSS一样,我们的POI生成的Excel同样需要样式才能更完美的表现我们的数据.下面还是从简单的例子出发,学习和了解POI的样式设计. 一.我的位置. package com.myja ...
- Servlet 中使用POI生成Excel
使用的是poi3.13 http://mvnrepository.com/artifact/org.apache.poi/poi/3.13 import java.io.IOException; im ...
- Java利用POI生成Excel强制换行
前一段时间在做一个学校排课系统时,有一个地方需要利用把课程表生成excel汇出给客户,由于之前用excel都只是简单的应用,在单元格里都是用自动换行,而这次可能需要用到手动强制换行. 于是我在网上找了 ...
随机推荐
- linux下目录简介——/SElinux
一.前言 安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统. SELinux 主要由美国 ...
- linux一些工具的安装(三)
linux(vmware15 centos7)中Docker安装 一.Docker卸载 1.查看已安装的docker安装包 $yum list installed|grep docker 执行后的 ...
- c# 程序只能运行一次(多次运行只能打开同一个程序)
转自:https://social.msdn.microsoft.com/Forums/zh-CN/6398fb10-ecc2-4c03-ab25-d03544f5fcc9/2291420309357 ...
- 基于javaMail的邮件发送--excel作为附件
基于JavaMail的Java邮件发送 Author xiuhong.chen@hand-china.com Desc 简单邮件发送 Date 2017/12/8 项目中需要根据物料资质的状况实时给用 ...
- vs2010直接调用av_register_all crash问题
需要做一个视频导出的功能,通过ffmpeg来实现,vs2010里面引用ffmpeg库的 dll 和 lib 文件 第一步av_register_all就直接crash了, 查了近半天的时间,都快崩溃了 ...
- JavaScript 高级特性
1. 原型Prototype 1.1 构造函数 所谓"构造函数",其实就是一个普通函数,但是内部使用了this变量.对构造函数使用new运算符,就能生成实例,并且this变量会绑定 ...
- 使用iframe方式获得svg中的DOM元素,和svg 的 contentDocument 返回 null
碰到这个的相关问题,百度找了好久,找到了个解决方法,原址 https://segmentfault.com/q/1010000009001758 var iframe = document.getEl ...
- 【linux】之日志查看
搜索日志 -n 显示行号 grep 1570xxxx -n callback.tomcat-catalina-out 显示从第多少行~多少行 sed -n '464913,465020p' callb ...
- 红米手机5 Plus完美刷成开发版获取root权限的教程
小米的设备不同手机型号通常情况小米官方都提供两个不同系统,可分为稳定版和开发版,稳定版没有提供ROOT超级权限管理,开发版中就提供了ROOT超级权限,较多时候我们需要使用的一些功能强大的工具,都需要在 ...
- 知识点:Mysql 索引原理完全手册(2)
知识点:Mysql 索引原理完全手册(1) 知识点:Mysql 索引原理完全手册(2) 知识点:Mysql 索引优化实战(3) 知识点:Mysql 数据库索引优化实战(4) 八. 联合索引与覆盖索引 ...