How to read font color of each text in cell in apache poi 3.9

Viewed 2258

[Text in 1 Cell]
ABC (Pink Color)
DEF (Black Color)
GHI (Red Color)

I have to check font color of text in cell like above. (I'm sorry that I can't upload image) Color of first row is pink. Color of next rows are black and red.

As you see, I can't use getCellStyle() method because the cell has 3 font attribute.

I typed source code like below.

XSSFCell cell = row.getCell(0);

XSSFRichTextString value = cell.getRichStringCellValue();

String[] info = value.getString().split("\n");

for(int i = 0; i < info.length; i++) {

int index = value.getString().indexOf(info);
System.out.println(value.getFontAtIndex(index).getColor());

}

But, I didn't get correct result. I want to know how I can get font information for each text.

Please inform me your great advice. Thank a lots. Have a good day!

1 Answers
Related