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都只是简单的应用,在单元格里都是用自动换行,而这次可能需要用到手动强制换行. 于是我在网上找了 ...
随机推荐
- GanttProject 如何显示今天和项目结束
GanttProject 如何显示今天和项目结束 GanttProject 在甘特图中可以很直观的看出项目开始和结束. 同时也可以看到今天的. 把今天的时间线打开,默认是关闭.
- tomcat 常用命令 网上找的资料
打开终端 cd /java/tomcat #执行 bin/startup.sh #启动tomcat bin/shutdown.sh #停止tomcat tail -f logs/catalina.ou ...
- 盘点海口最好吃的西餐厅top10
Top 1:主厨的餐桌 餐厅地址:龙华区海秀路九号民航宾馆一楼大堂 主厨的餐桌Chef's Table是三位志同道合的大厨一起携手开办的西餐厅,正宗的西式料理.浓郁的浪漫气息,都是Chef's Tab ...
- RabbitMq C# .net 教程
本文转载来自 [http://www.cnblogs.com/yangecnu/p/Introduce-RabbitMQ.html]写的很详细. 文件安装包官方DEMO下载地址是:http://pan ...
- Ubuntu 15.10 下Scala 操作Redis Cluster
1 前言 Redis Standalone,Redis Cluster的安装在前面介绍过,地址:http://www.cnblogs.com/liuchangchun/p/5063477.html,这 ...
- leetcode70 爬楼梯 Python
组合数学Fibonacci 例3.4.1 (上楼梯问题)某人欲登上n级楼梯,若每次只能跨一级或两级,问他从地面上到第n级楼梯,共有多少种不同的方法? (解)设上到第n级楼梯的方法数为an.分类统计 ...
- 廖雪峰Java9正则表达式-1正则表达式入门-2正则表达式匹配规则
正则表达式的匹配规则: 从左到右按规则匹配 匹配规则及示例 可以匹配 不能匹配 "abc" "abc" 不能匹配:"ab", "A ...
- qcom,msm8996-pinctrl.txt
Qualcomm Technologies, Inc. MSM8996 TLMM block This binding describes the Top Level Mode Multiplexer ...
- day3-三级目录
date = {"guangdong":{"guangzhou":{"tianhe":["tyx","zjxc ...
- windows下的Redis主从集群搭建
Redis官方不提供Windows版本,目前Windows下的版本是有微软开源团队(Microsoft Open Tech group)维护. http://redis.cn/ redis中文网 wi ...