apache-poi - 还有其他人在使用 Apache POI 向 Excel 添加纯色背景颜色时遇到问题吗?
问题描述
创建 Excel 电子表格时,我无法在 Apache POI 中使用纯色背景颜色。这是代码。
XSSFFont calibri_8 = workbook.createFont();
calibri_8.setFontHeight(8);
calibri_8.setColor(IndexedColors.BLACK.getIndex());
calibri_8.setBold(true);
XSSFCellStyle normalCenteredBeige_8_Wrapped = workbook.createCellStyle();
normalCenteredBeige_8_Wrapped.setWrapText(true);
normalCenteredBeige_8_Wrapped.setVerticalAlignment(
VerticalAlignment.CENTER);
normalCenteredBeige_8_Wrapped.setAlignment(HorizontalAlignment.CENTER);
normalCenteredBeige_8_Wrapped.setFont(calibri_8);
normalCenteredBeige_8_Wrapped.setFillBackgroundColor(new XSSFColor(
new Color(255, 235, 155), new DefaultIndexedColorMap()));
normalCenteredBeige_8_Wrapped.setFillPattern(
FillPatternType.SOLID_FOREGROUND);
我运行代码,输出看起来像这样。
应该有浅黄色背景的细胞是纯黑色的。在搜索了可用的文档后,似乎没有其他人遇到此问题。我很确定我正确地遵循了背景颜色的指南。非常感谢任何见解。我正在使用 POI 4.1.1。
解决方案
推荐阅读
- javascript - 如何在 Angular 8 应用程序中加载外部 Javascript
- xslt - 如何解决排序时发现的不可比较类型:无法将 xs:date 与 xs:integer 进行比较 - XSLT
- python - 如何检查 pandas 数据框中的列的值是否大于提到的值。如果该列的值作为列表
- emacs - org模式内链动态命名
- javascript - React.js - “无法读取未定义的属性‘地图’”
- c++ - 如何使用将字符串拆分为for循环中的变量的程序
- javascript - 反应:获取状态变量是未定义的错误
- c++ - 如何使用 redis-plus-plus 存储二进制数据,就像我想存储结构一样?@for_stack?
- c# - 发送电子邮件时 smtp 连接出错
- python - 如何为输出绘制图形,将第一个 col 作为标签,将第二个 col 作为值