/// <summary> /// Creates a SpreadSheetDocument from the specified /// template /// </summary> /// <param name="template">Template url</param> /// <returns>WordprocessingDocument reference</returns> public static WordprocessingDocument WordDocument(string template = null) { template = template ?? $@"{AppDomain.CurrentDomain.BaseDirectory}Extensions\Word\Templates\Document.docx"; if (!template.IsFilePath(out Uri path)) { return(null); } //Initialize via report template WordprocessingDocument document = WordprocessingDocument.CreateFromTemplate(template); //Compress using maximum value possible document.CompressionOption = CompressionOption.Maximum; //Bond the body of the document or else create a new one Body body = document.MainDocumentPart.Document.Body; //Add Document properties document.SetProperties(@"Documento"); //Add extended Document properties document.SetExtendedProperties(null, null); //Save all changes document.Save(); return(document); }