如何在Java Apache POI中获取excel单元格字段的字体样式?

如何在Java Apache POI中获取excel单元格字段的字体样式?,java,excel,fonts,apache-poi,Java,Excel,Fonts,Apache Poi,我想用Java捕获excel中单元格字段的字体。我正在使用ApachePOI。如果可能,我想捕获字体颜色,字体系列,字体重量,字体大小,等等 如何实现这一点?根据评论编辑 你可以参考,从中你可以得到答案。用它你可以得到,或者 基于我使用的示例单元格: XSSFCellStyle cs = cell.getCellStyle(); XSSFFont font = cs.getFont(); //Getting Font color XSSFColor color = font.getXSSFCo

我想用Java捕获excel中单元格字段的字体。我正在使用ApachePOI。如果可能,我想捕获
字体颜色
字体系列
字体重量
字体大小
,等等


如何实现这一点?

根据评论编辑

你可以参考,从中你可以得到答案。用它你可以得到,或者

基于我使用的示例单元格:

XSSFCellStyle cs = cell.getCellStyle();
XSSFFont font = cs.getFont();

//Getting Font color
XSSFColor color = font.getXSSFColor();
System.out.println("Font color : " + color.getARGBHex());
//==>   FF00B0F0

//Getting Font name
System.out.println("Font name : " + font.getFontName());
//==>   Arial

//Getting Font family name
FontFamily family = FontFamily.valueOf(((XSSFFont) font).getFamily());
System.out.println("Font family : " + family);
//==>   SWISS

//Getting Font family int
System.out.println("Font family in int : " + font.getFamily());
//==>   2

//Getting Font height
System.out.println("Font FontHeight : " + font.getFontHeight());
//==>   280

//Getting Font height in point
System.out.println("Font height in point : " + font.getFontHeightInPoints());
//==>   14

//Getting Font bold weight  
System.out.println("Font BoldWeight : " + font.getBoldweight());
//==>   700

我在Groovy中有它,但原理应该类似:

import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.ss.util.*
import java.io.*

InputStream file = new FileInputStream('C:\\Folder\\File.xls')
Workbook wb = WorkbookFactory.create(file)
Sheet sheet1 = wb.getSheet('Sheet1')
// to get first row
Row row = sheet1.getRow(0)
// to get first cell
Cell cell = row.getCell(0)
// to get its style
HSSFCellStyle cellStyle = cell.getCellStyle()
// to get font
HSSFFont cellFont = cellStyle.getFont(wb)
// to get font name as text
String cellFontName = cellFont.getFontName()

我可以用这个来获取CSSFColor,但是其他属性,如FontName、family、fontweight不能用这个来捕获