多种样式以Excel Cell POI

多种样式以Excel Cell POI,第1张

多种样式以Excel Cell POI

多个单元格样式不能应用于单个

Cell
。应用的最后一个单元格样式将覆盖上任何现有的单元格样式
Cell
。设置多个
CellStyle
不会合并每种样式的设置属性

解决方案是创建一个

CellStyle
具有其他两个属性的属性
CellStyle
。您可以使用该
cloneStyleFrom
方法以one的属性开头
CellStyle

CellStyle combined = workbook.createCellStyle();combined.cloneStyleFrom(colourCellStyle);combined.setDataFormat(dateCellStyle.getDataFormat());// You can copy other attributes to "combined" here if desired.cell9.setCellStyle(combined);

可以普遍使用此技术来克隆任何现有单元格样式并从第二种现有单元格样式复制单个属性。与往常一样,重用任何现有

CellStyle
,但是如果需要不同的属性组合,则必须创建并使用new
CellStyle



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5500107.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-12
下一篇2022-12-13

发表评论

登录后才能评论

评论列表(0条)

    保存