zoukankan      html  css  js  c++  java
  • 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);
        }
    

      

  • 相关阅读:
    window10+python3.7安装tensorflow--gpu tensorflow 安装
    解决plsql中文显示问号(???)问题
    卷积神经网络通俗解读
    NLP进阶之(七)膨胀卷积神经网络
    如何用简单易懂的例子解释条件随机场(CRF)模型?它和HMM有什么区别?
    【Learning Notes】线性链条件随机场(CRF)原理及实现
    【机器学习】【条件随机场CRF-2】CRF的预测算法之维特比算法(viterbi alg) 详解 + 示例讲解 + Python实现
    条件随机场(CRF)
    条件随机场(CRF)
    条件随机场(CRF)
  • 原文地址:https://www.cnblogs.com/gaoBlog/p/10724989.html
Copyright © 2011-2022 走看看