使用Apache Poi解析word文档中的表内表

发布于 2025-01-07 15:27:33 字数 99 浏览 5 评论 0原文

我能够使用 XWPFDocument 上的 getTablesIterator() 获取 Word 文档中存在的表格。 但是有没有办法在表中获取表呢?

提前致谢, 乔尔

I was able to get the tables present in a word document using getTablesIterator() on a XWPFDocument.
But is there a way to get table within a table?

Thanks in Advance,
Joel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈场末日恋爱 2025-01-14 15:27:33

在 .docx 中,“表”不直接包含其他表,但表单元格可以包含。因此,您不能向表格询问其嵌套表格,您必须获取每个单元格并检查它们。

从 XWPFTable 获取 XWPFTableRow 实例,然后从那里获取 XWPFTableCell。然后您可以调用 XPWFTableCell.getTables () 获取嵌套在该单元格中的任何表格。

In .docx "Table" doesn't directly contain other tables, but a Table Cell may do. So, you can't ask a table for its nested tables, you have to get each cell and check those.

From a XWPFTable get your XWPFTableRow instances, then from there a XWPFTableCell. You can then call XPWFTableCell.getTables() to get any tables nested in that one cell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文