//背景色、フォント色、枠線より各種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的生成的更多相关文章

  1. ExcelHelper----根据指定样式的数据,生成excel(一个sheet1页)文件流

    /// <summary> /// Excel导出类 /// </summary> public class ExcelHelper { /// <summary> ...

  2. JAVA POI 应用系列(1)--生成Excel

    POI简介(官网:http://poi.apache.org/)     Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office ...

  3. poi操作excel2007(读取、生成、编辑)

    因为现在再写excel2003版的比较low,所以我在这就不介绍了,直接介绍2007,我所用的编程软件是IDEA poi操作office总共有6个jar包,在pom.xml文件中配置如下,也可下载后直 ...

  4. 漂亮的CSS按钮样式集以及在线生成工具

    以前我们制作一样带带阴影.圆角或3D感的按钮都需要用图片来制作,但CSS3出来后就可以不用图片了,由于是代码写的按钮样式,在Retina上浏览依然清晰美观.虽然不错,但我们写一个阴影+质感的按钮还是挺 ...

  5. iText、poi操作word2007(读取,生成)

    关于生成word文件以及插入文字.表格.图片等功能,我使用了poi和itext,因为poi插入图片的jar包我在网上查并不是太完全,也可能我没找到如何使用,所以插入图片我用的是itext iText所 ...

  6. POI格式化Cell样式

    通过一个实例演示怎样通过POI设置Excel单元格的边框.字体.颜色.大小.下划线.合并.对齐方式. Excel文件如下: Java代码   package my.excel;       impor ...

  7. POI简易帮助文档系列--给Excel设置样式

    正如Html需要CSS一样,我们的POI生成的Excel同样需要样式才能更完美的表现我们的数据.下面还是从简单的例子出发,学习和了解POI的样式设计. 一.我的位置. package com.myja ...

  8. Servlet 中使用POI生成Excel

    使用的是poi3.13 http://mvnrepository.com/artifact/org.apache.poi/poi/3.13 import java.io.IOException; im ...

  9. Java利用POI生成Excel强制换行

    前一段时间在做一个学校排课系统时,有一个地方需要利用把课程表生成excel汇出给客户,由于之前用excel都只是简单的应用,在单元格里都是用自动换行,而这次可能需要用到手动强制换行. 于是我在网上找了 ...

随机推荐

  1. DEV中的TreeList控件应用的一个小效果实现——个人总结

    我使用最多的DEV控件就是这个TreeList啦,当然用好它很不简单,如果用好它,能做出很精彩的树形层次结构图.TreeList控件很强大,以至于你看DEV自带的DEMO,也得浪费你很长时间应用.DE ...

  2. dbca建库--linux上使用vnc图形化安装oracle10g版本

    选择创建数据库 配不配置em,自己决定,我们选择配置 配置下面账户密码,在项目中,下面账户肯定是不相同的,我们这里输入相同的,密码为oracle10g 选择文件系统存放(asm和字符设备暂时不能存放) ...

  3. java中super关键字的作用

    1.super关键字可以在子类的构造方法中显示地调用父类的构造方法,super()必须为子类构造函数中的第一行. 2.super可以用来访问父类的成员方法或变量,当子类成员变量或方法与父类有相同的名字 ...

  4. sharding sphere 分表分库 读写分离

    sharding jdbc: sharding sphere 的 一部分,可以做到 分表分库,读写分离. 和 mycat 不同的 是 sharding jdbc 是 一个 jdbc 驱动 在 驱动这个 ...

  5. python selenium-webdriver 定位frame中的元素 (十三)

    定位元素时经常会出现定位不到元素,这时候我们需要观察标签的上下文,一般情况下这些定位不到的元素存放在了frame或者放到窗口了,只要我们切入进去就可以很容易定位到元素. 处理frame时主要使用到sw ...

  6. delphi 多线程之 TEvent 和 TLightweightEvent

    unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...

  7. Tcl 编译成tbc文件

    工具:tclpro1.4 下载地址:https://www.tcl.tk/software/tclpro/eval/1.4.html 永久license:  Version 1.4: 1094-320 ...

  8. 排产的两种方式(前推式与后拉式)在Optaplanner上的体现

    生产计划的约束 在制定生产计划过程中,必然是存在某些制约因素,满足某些需求才能进行的,或是交期保证.或是产能限制.或是关键工序制约.即TOC理论 - 任何系统至少存在着一个制约因素/瓶颈:否则它就可能 ...

  9. Difference Between Git and SVN

    From: http://www.differencebetween.net/technology/software-technology/difference-between-git-and-svn ...

  10. JavaScript问题——在浏览器中每一个元素都有一个offsetParent属性,这个属性是什么?

    原文链接http://www.cnblogs.com/zcjnever/archive/2011/04/21/2023133.html Javascript中的offsetParent属性 支持的浏览 ...