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

这篇博客介绍了如何在Java中利用Apache POI库获取Excel单元格的字体属性,包括颜色、名称、家族、大小、粗细等信息。通过示例代码展示了获取字体颜色、名称、家族名、大小(点数和整数形式)以及粗细权重的方法。
摘要由CSDN通过智能技术生成

I would like to capture the font of a cell field in excel in Java. I am using Apache POI. If possible, I would like to capture font-color, font-family, font-weight, font-size, etc.

How can I achieve this?

解决方案

Edited based on comment

Based on example cell that I've used:

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值