简体   繁体   English

使用Apache POI在Word文档中添加不可见的段落

[英]add an invisible paragraph in a word document using Apache POI

I have a word document (.docx) that contains some information, I want to edit this document and add to it some text , I want that the text still invisible when I open the document but I want also to access to it easily from my code. 我有一个包含一些信息的word文档(.docx),我想编辑该文档并向其中添加一些文本,我希望打开文档时该文本仍然不可见,但我也想从我的文档中轻松访问它。码。
Do you have please any idea how can I proceed ? 您是否知道我该如何进行?

I was in fact looking for a solution with ApachePOI to make my text invisible in the generated word document.After some researches, I found this solution: 我实际上是在寻找一种使用ApachePOI的解决方案来使我的文本在生成的Word文档中不可见。经过一些研究,我发现了以下解决方案:

for (XWPFParagraph paragraph : doc.getParagraphs()){
for(XWPFRun run : paragraph.getRuns()){
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
run.getCTR().getRPr().setVanish(onoffnull);
}
}

this code make all paragraphs of a word document invisible by the user. 此代码使Word文档的所有段落都对用户不可见。

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

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