XSSFWorkbook CellStyle 第一行背景色
时间: 2023-10-16 08:05:16 浏览: 184
要为XSSFWorkbook的CellStyle设置第一行的背景色,你可以使用以下代码:
```
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(156, 195, 230)));
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
```
在这段代码中,我们首先创建了一个XSSFWorkbook对象,然后创建了一个XSSFCellStyle对象。接下来,我们使用`setFillForegroundColor`方法设置了背景色,并使用`setFillPattern`方法设置了填充模式。通过这样设置,你可以为XSSFWorkbook的CellStyle对象的第一行设置背景色。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [XSSFWorkbook设置行背景色、自定义背景色、单元格合并后加边框](https://blog.csdn.net/xiaoxiangzi520/article/details/100540147)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [java通过CellStyle设置单元格背景颜色](https://blog.csdn.net/weixin_45151960/article/details/127076062)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文