[英]get image from table cell in docx in openxml c#
Aim: I want to get image from inside of table cell in word document using OpenXML with C#.目标:我想使用 OpenXML 和 C# 从 Word 文档中的表格单元格内部获取图像。 But I dont know which method to use for it.但我不知道该使用哪种方法。
string questionText = cells[1].InnrerText
var questionImage = cells[1]. // <<------ What method to try here?
The general approach for questions like this is to:此类问题的一般方法是:
w:tc
, w:p
, w:drawing
, a:graphic
, a:blip
) you want to create, read, update, or delete;确定要创建、读取、更新或删除的 Open XML 元素(例如, w:tc
、 w:p
、 w:drawing
、 a:graphic
、 a:blip
);TableCell
(for w:tc
), TableCell
(对于w:tc
),Paragraph
(for w:p
), Paragraph
(对于w:p
),Drawing
(for w:drawing
), Drawing
(对于w:drawing
),Graphic
(for a:graphic
), and Graphic
(对于a:graphic
),和Blip
(for a:blip
); Blip
(对于a:blip
); and和use the desired class name, eg, as follows:使用所需的类名,例如,如下:
var blip = cells[1].Descendants<Blip>().FirstOrDefault();
The above example assumes you want the Blip
to identify the ImagePart
that contains the image data.上面的示例假设您希望Blip
识别包含图像数据的ImagePart
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.