使用 Open XML 过滤表列的内容

发布于 2024-10-01 11:25:47 字数 664 浏览 0 评论 0原文

我需要使用 openxml sdk 过滤表列的内容(在 MS-word 文档中)。我可以使用 reference = tablerow.ElementAt(0).InnerText 获取表列内容(作为字符串)

我需要做的是将列的内容拆分为多个字符串,例如: 列

abcd 

efgh

我使用 reference = tablerow.ElementAt(0).InnerText 在参考中获取 abcdefgh

我需要的是拆分 abcdefgh 转换成不同的字符串。

这是我正在使用的代码:

foreach (Table table in tables)
{
    foreach (TableRow tablerow in table.Descendants<TableRow>())
    {
        reference = tablerow.ElementAt<OpenXmlElement>(0).InnerText
    }
}

I need to filter contents of table column(in MS-word document) using openxml sdk. I am able get table column contents(as string) using reference = tablerow.ElementAt<OpenXmlElement>(0).InnerText

What I need to do is split the content of column into muliple strings for eg:
column

abcd 

efgh

I am getting abcdefgh in reference using reference = tablerow.ElementAt<OpenXmlElement>(0).InnerText

What I need is to split abcd and efgh into different strings.

This the piece of code which I am using:

foreach (Table table in tables)
{
    foreach (TableRow tablerow in table.Descendants<TableRow>())
    {
        reference = tablerow.ElementAt<OpenXmlElement>(0).InnerText
    }
}

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

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

发布评论

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

评论(1

合久必婚 2024-10-08 11:25:47

如果我正确理解你的问题,你只想将字符串拆分为子字符串。您可以使用 substring拆分 从 foreach 循环中获取的引用 字符串。

If I understand your question correctly you just want to split up a string into substrings. You can do that by using substring or split on the reference string that you get from your foreach loop.

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