我如何获得一个给定的单元格(Java的Apache的POI HSSF)背景颜色? [英] How do I get the (Java Apache POI HSSF) Background Color for a given cell?
问题描述
我有一个现有的Excel US preadsheet,这我accesssing和,我使用Apache POI HSSF读值。
I have an existing excel spreadsheet, which I am accesssing and reading values from, I am using Apache POI HSSF.
据初始化是这样的:
HSSFSheet sheet;
FileInputStream fis = new FileInputStream(this.file);
POIFSFileSystem fs = new POIFSFileSystem(fis);
HSSFWorkbook wb = new HSSFWorkbook(fs);
this.sheet = wb.getSheet(exsheet);
我遍历中存在的表,这使得电池对象中所有单元格:
I am iterating over all the cells that exist in the sheet, which makes a cell object:
HSSFCell cell = (HSSFCell) cells.next();
请有人可以熟悉该框架介绍了如何创建一个(HSSFColor)对象重新present在表每个单元格的底色颜色。
Please can someone familiar with the framework explain how to create an (HSSFColor) object to represent the backround color of each cell in the sheet.
非常感谢
编辑,更新
要明确什么我想知道的是:我怎么创建/获得的 HSSFColor 对象为现有的单元格的背景颜色
To be clear what I want to know is: how do I create/get an HSSFColor object for the background color of an existing cell?
cell.getCellStyle().getFillBackgroundColor();
这code只返回一个短号码,而不是一个HSSFColor对象。
感谢迄今答案。
This code only returns a short number, not an HSSFColor object. Thanks for the answers so far.
推荐答案
有由HSSFCell类提供静态的色彩班,这里列出:
There are static color classes provided by the HSSFCell class, listed here:
<一个href=\"http://poi.apache.org/apidocs/org/apache/poi/hssf/util/HSSFColor.html\">http://poi.apache.org/apidocs/org/apache/poi/hssf/util/HSSFColor.html
如果你想创建自己的自定义颜色,则需要创建和修改自定义调色板。 Apache提供了一个非常明确的指导,这也:
If you want to create your own custom colors, you will need to create and modify a custom palette. Apache provides a very clear guide to this as well:
<一个href=\"http://poi.apache.org/s$p$padsheet/quick-guide.html#CustomColors\">http://poi.apache.org/s$p$padsheet/quick-guide.html#CustomColors
这篇关于我如何获得一个给定的单元格(Java的Apache的POI HSSF)背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!