简体   繁体   English

如何使用 Apache POI PPT API 设置文本高亮?

[英]How to set text hightlight using Apache POI PPT API?

I'm using apache poi to process ppt.I can get the CTTextCharacterProperties of a CTRegularTextRun by using method CTRegularTextRun's getRPr(),and then I can find a method setHighlight(CTColor var1) in interface CTTextCharacterProperties,but I don't know how to make text content being highlighted.does anyone can help me?我正在使用apache poi处理ppt。我可以通过使用方法CTRegularTextRun的getRPr()获取CTRegularTextRun的CTTextCharacterProperties,然后我可以在接口CTTextCharacterProperties中找到方法setHighlight(CTColor var1),但我不知道如何使文本内容突出显示。有人可以帮助我吗?

CTTextParagraph paragraph=new CTTextParagraph();
List<CTRegularTextRun> rList = paragraph.getRList();
for(CTRegularTextRun run:rList){
   CTTextCharacterProperties rPr=run.getRPr();
   CTColor ctColor=rPr.isSetHighlight()==true?rPr.getHighlight():rPr.addNewHighlight();
   CTSRgbColor srgbClr=ctColor.isSetSrgbClr()==true?ctColor.getSrgbClr():ctColor.addNewSrgbClr();
   byte[] rgbBytes = {(byte) Color.GREEN.getRed(), (byte) Color.GREEN.getGreen(), (byte) Color.GREEN.getBlue()};
   srgbClr.setVal(rgbBytes);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM