如何使用ApachePOIPPTAPI设置文本高亮?

pw136qt2  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(477)

我用ApachePOI来处理ppt,我可以用方法ctregulartextrun的getrpr()得到ctregulartextrun的cttextcharacterproperties,然后我可以在接口cttextcharacterproperties中找到方法sethighlight(ctcolor var1),但是我不知道如何突出显示文本内容,有人能帮我吗?

cedebl8k

cedebl8k1#

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);
}

相关问题