如何使用 Apache POI 为 Excel 工作表中的行应用背景颜色? [英] How to apply background color for the rows in excel sheet using Apache POI?

查看:32
本文介绍了如何使用 Apache POI 为 Excel 工作表中的行应用背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Apache POI 将数据导出到 Excel 表中.它工作正常.问题是我需要在生成excel表时为excel表中的几行应用黄色背景色.请帮助我如何在生成时为 Excel 表的行应用背景颜色.

I am using Apache POI for exporting data into excel sheet. it works fine. the problem is i need apply yellow background color for few rows in the excel sheet while generating the excel sheet. please hellp me how to apply background color for the rows of excel sheet while generating.

谢谢,雷迪

推荐答案

直接来自官方指南:

    // Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(CellStyle.BIG_SPOTS);
row.setRowStyle(style);

这篇关于如何使用 Apache POI 为 Excel 工作表中的行应用背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆