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都只是简单的应用,在单元格里都是用自动换行,而这次可能需要用到手动强制换行. 于是我在网上找了 ...
随机推荐
- nginx ngx_http_image_filter_module 简单试用
nginx包含了一个ngx_http_image_filter_module 模块,我们可以方便的进行图片的缩略图,平时一些简单的功能 已经够用了 环境准备 为了简单使用docker-compose ...
- java8_api_字符串处理
字符串处理1 字符串处理2 string的常用方法 package java_20180209_api_string; public class StringDemo2 { public sta ...
- mysql入门学习笔记
MySQL的登陆和退出 mysql -u 用户名 -p 密码 #登陆 quit #退出(exit or \q) 具体参数: 参数 描述 -D,--database=name 打开指定数据库 -deli ...
- 注解@Resource和@Autowired区别对比
@Resource和@Autowired都是做bean的注入时使用,其实@Resource并不是Spring的注解,它的包是javax.annotation.Resource,需要导入,但是Sprin ...
- 利用工具将数据库中的表导出到word中
1.动软代码生成器 效果图: 数据库设计说明书中的一项,刚好我负责写这个文档, 18张表,前两张表是自己画表格自己填充内容,写到第三张表的时候就已经崩溃了(我觉得我耐力还是够的,怎么说也画完了两张表呢 ...
- Eclipse中Java build path的使用
1.Eclipse中,工程属性的Java Build Path的Library标签页下,有如下几个按钮:Add Jars...添加JAR包,是指本Eclipse当前包含的工程中的,在工程列表下选取即可 ...
- Oracle数据csv导入
打开工具,在tool下面有个Text Importer 先选择Data from textfile选项卡 然后选择 Open data file ,打开要导入的文件 1\ 2\ 再先选择Data to ...
- 时间规划在Optaplanner上的实现
在与诸位交流中,使用较多的生产计划和路线规划场景中,大家最为关注的焦点是关于时间的处理问题.确实,时间这一维度具有一定的特殊性.因为时间是一维的,体现为通过图形表示时,它仅可以通过一条有向直线来表达它 ...
- 工控随笔_19_西门子_WinCC的VBS脚本_08_常量和流程控制_01
在编程的过程中,有时候我们会使用一些固定的值,例如圆周率,或者某个人的生日,或者家庭住址等等, 这些信息对于一个对象来说一旦确定就不会改变,因此我们在编程的时候也不希望这些信息会改变,在VBS里面 也 ...
- RDLC报表系列--------报表分页显示标题
RDLC表格标题分页后,标题不显示网上的办法也不少.怎奈我试过很多,只有这个可以解决.留下代码以后使用 将报表以 XML的方式打开,搜索找到“详细信息” 在这个位置 报表分页标题设置<Tabli ...