예제 #1
0
        public HttpResponseMessage MailMerge([FromBody] ExportData exportData)
        {
            Byte[]       data   = Convert.FromBase64String(exportData.documentData.Split(',')[1]);
            MemoryStream stream = new MemoryStream();

            stream.Write(data, 0, data.Length);
            stream.Position = 0;
            try
            {
                Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);
                document.MailMerge.RemoveEmptyGroup      = true;
                document.MailMerge.RemoveEmptyParagraphs = true;
                document.MailMerge.ClearFields           = true;
                document.MailMerge.Execute(CustomerDataModel.GetAllRecords());
                document.Save(stream, Syncfusion.DocIO.FormatType.Docx);
            }
            catch (Exception)
            { }
            string          sfdtText     = "";
            EJ2WordDocument worddocument = EJ2WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);

            sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(worddocument);
            worddocument.Dispose();
            return(new HttpResponseMessage()
            {
                Content = new StringContent(sfdtText)
            });
        }
예제 #2
0
        public string ImportWordDocument(Stream stream)
        {
            string          sfdtText = "";
            EJ2WordDocument document = EJ2WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);

            sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(document);
            document.Dispose();
            return(sfdtText);
        }
예제 #3
0
        public HttpResponseMessage Import()
        {
            if (HttpContext.Current.Request.Files.Count == 0)
            {
                return(null);
            }

            HttpPostedFile file  = HttpContext.Current.Request.Files[0];
            int            index = file.FileName.LastIndexOf('.');
            string         type  = index > -1 && index < file.FileName.Length - 1 ?
                                   file.FileName.Substring(index) : ".docx";
            Stream stream = file.InputStream;

            stream.Position = 0;

            EJ2WordDocument document = EJ2WordDocument.Load(stream, GetFormatType(type.ToLower()));
            string          json     = Newtonsoft.Json.JsonConvert.SerializeObject(document);

            document.Dispose();
            return(new HttpResponseMessage()
            {
                Content = new StringContent(json)
            });
        }