<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] # 1. 使用POI提供的顏色 ```java //獲取樣式對象 CellStyle cellStyle = workbook.createCellStyle(); //設置顏色樣式 cellStyle.setFillBackgroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); cellStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); SXSSFRow row = sheet.createRow(i + 1); SXSSFCell cell = row.createCell(0); //將樣式用到單元格中 cell.setCellStyle(cellStyle); ``` 設置單元格背景顏色如下: ![](https://img.kancloud.cn/dc/c1/dcc15b5b2fdc971a321091fa3e705c00_1519x172.png) <br/> # 2. 自定義顏色 HSSF與XSSF、SXSSF自定義顏色的方式有所不同。 <br/> **1. HSSF自定義顏色** ```java //創建文檔對象 HSSFWorkbook workbook = new HSSFWorkbook(); //獲取HSSFPalette HSSFPalette palette = workbook.getCustomPalette(); //將 IndexedColors.BRIGHT_GREEN.getIndex() 所代表的顏色重寫為 (byte) 0, (byte) 176, (byte) 80 顏色 palette.setColorAtIndex(IndexedColors.BRIGHT_GREEN.getIndex(), (byte) 0, (byte) 176, (byte) 80); //設置顏色樣式 CellStyle cellStyle = workbook.createCellStyle(); //調用 IndexedColors.BRIGHT_GREEN.getIndex() cellStyle.setFillBackgroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); cellStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); HSSFRow row = sheet.createRow(i + 1); HSSFCell cell = row.createCell(2); //將樣式用到單元格中 cell.setCellStyle(cellStyle); ``` 自定義的顏色如下: ![](https://img.kancloud.cn/1d/a0/1da06c8c69de82a307d6879603090f3b_1592x162.png) <br/> **2. XSSF、SXSSF自定義顏色** ```java SXSSFWorkbook workbook = new SXSSFWorkbook(); ... //自定義顏色 XSSFColor xssfColor = new XSSFColor(new java.awt.Color(0, 176, 80), new DefaultIndexedColorMap()); //設置背景顏色樣式 XSSFCellStyle cellStyle = (XSSFCellStyle) workbook.createCellStyle(); cellStyle.setFillBackgroundColor(xssfColor); cellStyle.setFillForegroundColor(xssfColor); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); ... SXSSFCell genderCell = row.createCell(2); //設置單元格樣式 genderCell.setCellStyle(cellStyle); ... ``` 自定義的顏色如下: ![](https://img.kancloud.cn/1d/a0/1da06c8c69de82a307d6879603090f3b_1592x162.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看