#region Insert Images
public string InsertImage(XmlWriter writer, string imageType, string imageUrl)
{
// create the new image part
if (File.Exists(imageUrl))
{
FileInfo fi = new FileInfo(imageUrl);
Uri imageUri =
new Uri("/word/media/" + fi.Name,
UriKind.Relative);
package.CreateNewPart(imageUri, imageType,
imageUrl);
// create the relationship between the document and the image
string ImageRelId = package.CreateInternalRelationship(
new Uri(@"/word/document.xml", UriKind.Relative),
imageUri, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
OpenXml开发-向文档中插入图片
最新推荐文章于 2021-06-02 21:17:33 发布