在表格单元格中获取HTML文本 [英] Getting HTML text with in a table cell
问题描述
嗨
我使用Open XML来读取单元格内的值。我可以使用innerText属性获取表格单元格内的纯文本,如下所示 -
I am using Open XML to read the values inside the cell. I am able to get the plain text inside the cell of a table using innerText property as shown below -
TableRow row = table.Elements< TableRow>()。ElementAt(0);
DocumentFormat.OpenXml.Wordprocessing.TableCell cell = row.Elements< DocumentFormat.OpenXml.Wordprocessing .TableCell>()。ElementAt(1);
$
String value = cell.InnerText;
TableRow row = table.Elements<TableRow>().ElementAt(0);
DocumentFormat.OpenXml.Wordprocessing.TableCell cell = row.Elements<DocumentFormat.OpenXml.Wordprocessing.TableCell>().ElementAt(1);
String value = cell.InnerText;
我想知道如何使用open xml api在单元格内直接获取富文本。
I would like to know how can I get directly rich text inside the cell using the open xml api.
谢谢
Prashant
prashant
推荐答案
嗨phkadse,
Hi phkadse,
据我所知,没有API /方法将单元格的值作为html获取。我们需要自己做。
As far as I know, there isn’t the API/Method to get the cell’s value as html. We need do it by ourself.
我们需要获得 ParagraphProperties 和 RunProperties ,然后获取详细信息属性,例如
颜色。
We need to get ParagraphProperties and RunProperties, then get the detail properties, such as Color.
有一个链接可能对您有所帮助:
There is a link that may benefit you:
#Html to OpenXml
https://html2openxml.codeplex.com/documentation
最好的问候
Starain
这篇关于在表格单元格中获取HTML文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!