如何用poi打开word文档的特定段落?
要求是这样的...
我们正在阅读Word文档并从该文档中获取所有注释,并且我们正在将该文档发送给用户,当用户打开该文档时,该文档应该以某些特定页面特定段落打开。 (我们可以提供特定的页面、段落位置,我可以提供 org.apache.poi.hwpf.usermodel.Range 对象。)
请提供一些示例代码来执行此功能...
感谢您的帮助...
Requirement is this ...
We are reading word document and getting all annotation from that document, and we are sending this document to user, when user open the document that time document should open with some specific page specific paragraph. ( That specific page, paragraph location we can give it, I can give the org.apache.poi.hwpf.usermodel.Range object. )
Please provide some example code to do this functionality ...
Appreciate you help ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Apache POI 无法实现这一点。
我能想到的让 Microsoft Word 在打开文档时滚动到特定范围的唯一方法是包含一个选择范围的
AutoOpen
VBA 宏。例如,要选择第 9 段,您必须包含以下 VBA 代码(不言而喻,这仅在启用宏的情况下才有效):
There is no way this can be achieved using Apache POI.
The only way I can think of to have Microsoft Word scroll to a specific range when a document is opened would be to include an
AutoOpen
VBA macro that selects the range.For example, to make the 9th paragraph be selected you would have to include the following VBA code (it goes without saying that this only works if macros are enabled):