如何使用openxml插入图像?

时间:2014-03-14 09:53:33

标签: openxml-sdk

如何将图像插入word文档,其中word文档由一个表组成,该图像应插入其中一个表格单元格中如何做?请帮帮我

1 个答案:

答案 0 :(得分:2)

查看MSDN上的How to: Insert a picture into a word processing document (Open XML SDK)文章。它将帮助您inserting images提供docuemnt。

同样Working with WordprocessingML tables (Open XML SDK)How to: Insert a Table into a Word Processing Document将帮助您在OpenXml中使用Tables

更新:

我假设您通过http://msdn.microsoft.com/en-us/library/cc850841(v=office.14).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-6中提到的代码在文档中获得了所需的单元格(因此您将 <{1}} 变量中的TableCell放在了一起),而且我还假设您已根据http://msdn.microsoft.com/en-us/library/office/bb497430(v=office.15).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-5中提到的代码将所需图片添加到文档中(因此您在 tc2 varialbe中有图像参考)

所以只需运行此代码即可将图片添加到 tc2 表格单元格中:

element