使用Java在XSSFWorkbook中设置BackgroundColor [英] Set BackgroundColor in XSSFWorkbook with Java
本文介绍了使用Java在XSSFWorkbook中设置BackgroundColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在XSSFWorkbook中设置自己的背景色. 到目前为止,我有以下代码:
I want to set my own backgroundcolor in XSSFWorkbook. So far i have this code:
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.RIGHT);
style.setFont(itemFont);
style.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128)));
styles.put("item_right", style);
但是我遇到了以下错误:
But i got the following error:
CellStyle类型的setFillForegroundColor(short)方法不适用于参数(XSSFColor)
The method setFillForegroundColor(short) in the type CellStyle is not >applicable for the arguments (XSSFColor)
不推荐使用构造函数XSSFColor(Color)
The constructor XSSFColor(Color) is deprecated
那么我如何在XSSFWorkbook中设置自己的颜色?
So how can i set my own color in XSSFWorkbook ?
推荐答案
解决方案之一:
style.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128), null));
最新版本未弃用.
这篇关于使用Java在XSSFWorkbook中设置BackgroundColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文