apache-poi - 如何在 apache poi 4.0 中将单元格的颜色设置为 RGB 值
问题描述
此处的示例无法编译。setFillForegroundColor 现在似乎需要一个索引,我可以欺骗它以显示特定的颜色,但是尝试任何指定 rgb 值的方法只会创建一个黑色单元格。
下面是 apache 自己的示例,它似乎与 4.0.0 过时了。 https://poi.apache.org/components/spreadsheet/quick-guide.html#CustomColors
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell( 0);
cell.setCellValue("custom XSSF colors");
XSSFCellStyle style1 = wb.createCellStyle();
style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128)));
style1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
解决方案
推荐阅读
- ag-grid - ag-grid 使用隐藏列 B 按列 A 排序
- python - 如何在有条件的数据框中选择行?
- node.js - 如何修复代码:'ERR_INVALID_CALLBACK' nodejs
- installation - Magento 2.4.2 - 将全新安装安装到子目录中 - 不起作用?
- typescript - 对于泛型函数,类型推断无法按预期工作
- traveling-salesman - 距离约束取决于第一个访问节点的车辆路径问题
- sql - 如何使用 sql 查询在 ms 访问中选择具有两个不同邮政编码的记录
- typescript - 如何将对象注释为函数参数?
- iis - Internet Information Services (IIS) 10 Express 错误:无法读取配置文件
- unix - UNIX - 来自列表文件的 Grep 2 行相同