In the program, the user selects files that can be attached to the docx file. I added the pictures. How to add xlsx and pdf (desirable).
Library used: DocumentFormat.OpenXml.
So I add images to the document:
public static void InsertAPicture(WordprocessingDocument wordprocessingDocument, MainDocumentPart mainPart, string fileName) { ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg); System.Drawing.Image img = System.Drawing.Image.FromFile(fileName); var width = img.Width; var height = img.Height; img.Dispose(); using (FileStream stream = new FileStream(fileName, FileMode.Open)) { imagePart.FeedData(stream); } AppenderToDoc.AddImageToBody(wordprocessingDocument, mainPart.GetIdOfPart(imagePart), width, height); mainPart.Document.Body.AppendChild(new Paragraph()); } There is an example: https://code.msdn.microsoft.com/office/How-to-embed-Excel-sheet-e4c252b5 . But there the docx image is added when you click on which opens the xlsx document. And I need the contents of this document (xlsx) to be inserted into the docx.
Waiting for any suggestions.
EmbedExcelIntoWordDoc.Properties.Resource1.BASE64_STRING_EXCEL_ICONwrites I do not know what to connect. - endovitskiiy