如何获取XSSFCell
的背景颜色
。我尝试使用XSSFCellStyle
但没有成功。
FileInputStream fis = new FileInputStream(fileName);
XSSFWorkbook book = new XSSFWorkbook(fis);
XSSFSheet sheet = book.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
System.out.println(row.getCell(0).getCellStyle().getFillForegroundColor());
使用这些步骤,我无法在
Short
类型中获得背景颜色表示。
cell.getCellStyle().setFillForegroundColor(HSSFColor.GOLD.index);
System.out.println(cell.getCellStyle().getFillForegroundColor());
它会给你51...这意味着它正在工作并根据所得到的颜色进行更改。 - Sankumarsingh