private void ReplaceWordContent(CashFlowInformation information) { DirectoryInfo directoryInfo = DirectoryHelper.GetWordTemplateDirectory(); string source = Path.Combine(directoryInfo.FullName, information.WordDocument); foreach (CashFlowDetail detail in information.InvestorDetails) { FillStrings(detail); RadFlowDocument wordDocument = new RadFlowDocument(); try { using (Stream input = File.OpenRead(source)) { wordDocument = provider.Import(input); } } catch (Exception ex) { throw new Exception($"Das Word-Template konnte nicht geöffnet werden. {ex.Message}"); } editor = new RadFlowDocumentEditor(wordDocument); ReplacePlaceholder(detail); //add docuemnt to seriesDocument seriesDocument.Merge(editor.Document); // save single file string fileName = DirectoryHelper.FindInvestorCashFlow(detail.Investor.Id, cashFlowNumber); using (Stream output = File.OpenWrite(fileName)) { provider.Export(editor.Document, output); } eventAggregator.GetEvent <StatusBarEvent>().Publish($"Das Ausschüttungsschreiben für {detail.Reference} wurde erstellt."); detail.FileName = fileName; } string seriesFileName = DirectoryHelper.FindFundCashFlow(information.Fund.Id, cashFlowNumber); using (Stream output = File.OpenWrite(seriesFileName)) { provider.Export(seriesDocument.Document, output); } CommonProcesses.StartWord(seriesFileName); }
protected override void WriteToFile() { using (var wordStream = File.Open(OutputFileLocation, FileMode.Create)) { var docxFormatProvider = new DocxFormatProvider(); docxFormatProvider.Export(Document, wordStream); } }
private void SaveFile(RadFlowDocument document) { using (Stream stream = File.OpenWrite("Mail Merge Sample.docx")) { DocxFormatProvider formatProvder = new DocxFormatProvider(); formatProvder.Export(document, stream); } }
private void ExportToArray() { #region radwordsprocessing-formats-and-conversion-docx-docxformatprovider_3 DocxFormatProvider provider = new DocxFormatProvider(); RadFlowDocument document = CreateRadFlowDocument(); byte[] output = provider.Export(document); #endregion }
private void ExportToDocx(RadFlowDocument document) { #region radwordsprocessing-getting-started_1 using (Stream output = new FileStream("output.docx", FileMode.OpenOrCreate)) { DocxFormatProvider provider = new DocxFormatProvider(); provider.Export(document, output); } #endregion }
private void ExportToFile() { #region radwordsprocessing-formats-and-conversion-docx-docxformatprovider_2 DocxFormatProvider provider = new DocxFormatProvider(); using (Stream output = File.OpenWrite("Sample.docx")) { RadFlowDocument document = CreateRadFlowDocument(); provider.Export(document, output); } #endregion }
public CreateClientLetterTelerik(string sourcePath, string saveAsFile, CashFlowInformation information, CashFlowDetail detail) { this.sourcePath = sourcePath; SaveAsFile = saveAsFile; this.information = information; this.detail = detail; FillStrings(detail); RadFlowDocument wordDocument = new RadFlowDocument(); provider = new DocxFormatProvider(); try { using (Stream input = File.OpenRead(sourcePath)) { wordDocument = provider.Import(input); } } catch (Exception ex) { throw new Exception($"Das Word-Template konnte nicht geöffnet werden. {ex.Message}"); } editor = new RadFlowDocumentEditor(wordDocument); ReplacePlaceholder(detail); int pos = saveAsFile.LastIndexOf("."); string fileName = saveAsFile.Substring(0, pos) + ".docx"; using (Stream output = File.OpenWrite(fileName)) { provider.Export(editor.Document, output); } string pdfFile = fileName.Replace(".docx", ".pdf"); // cpmversion of a flowdocument to a fixeddocument PdfFormatProvider pdfProvider = new PdfFormatProvider(); RadFixedDocument fixedDocument = pdfProvider.ExportToFixedDocument(editor.Document); // write the fixeddocuement to file Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixedProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider(); using (Stream output = File.OpenWrite(pdfFile)) { fixedProvider.Export(fixedDocument, output); } }
private void SaveFile(RadFlowDocument document) { string path = "Mail Merge Sample.docx"; using (Stream stream = File.OpenWrite(path)) { DocxFormatProvider formatProvder = new DocxFormatProvider(); formatProvder.Export(document, stream); } Process.Start(path); Console.Write("Mail merge finished - the document is saved."); }
public ActionResult ExportDocx(string content) { HtmlFormatProvider htmlProvider = new HtmlFormatProvider(); RadFlowDocument htmlDocument = htmlProvider.Import(content); DocxFormatProvider docxProvider = new DocxFormatProvider(); using (Stream output = System.IO.File.OpenWrite(Server.MapPath("~/App_Data/Sample.docx"))) { docxProvider.Export(htmlDocument, output); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
private void btnPrint_Click(object sender, EventArgs e) { IDocumentFormatProvider provider = new DocxFormatProvider(); using (Stream output = (Stream)File.Open("print.docx", FileMode.Create)) { provider.Export(this.docCertificate.Document, output); } try { ProcessStartInfo info = new ProcessStartInfo("print.docx"); info.Verb = "PrintTo"; info.CreateNoWindow = true; info.ErrorDialog = false; info.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(info); } catch { } }
private void SaveFile(RadFlowDocument document) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Docx File (*.docx)|*.docx"; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { DocxFormatProvider formatProvder = new DocxFormatProvider(); formatProvder.Export(document, stream); } } }
private void bSaveAsDocument_Click(object sender, EventArgs e) { compileDocument(); saveDialog.FileName = chosenPerson.getName(); saveDialog.FilterIndex = 1; DialogResult dialogResult = saveDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { using (Stream output = saveDialog.OpenFile()) { docxProvider.Export(doc, output); } } }
protected void exportDOCX(RadFlowDocument doc) { IFormatProvider <RadFlowDocument> formatProvider = new DocxFormatProvider(); byte[] renderedBytes = null; using (MemoryStream ms = new MemoryStream()) { formatProvider.Export(doc, ms); renderedBytes = ms.ToArray(); } Response.ClearHeaders(); Response.ClearContent(); Response.AppendHeader("content-disposition", "attachment; filename=ExportedFile.docx"); Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; Response.BinaryWrite(renderedBytes); Response.End(); }
private async void GenerateSampleExecute() { if (this.sampleDocument == null) { this.sampleDocument = this.OpenSample(); } IFormatProvider <RadFlowDocument> formatProvider = new DocxFormatProvider(); string exampleName = "example.docx"; using (MemoryStream stream = new MemoryStream()) { formatProvider.Export(this.sampleDocument, stream); stream.Seek(0, SeekOrigin.Begin); await this.fileViewerService.View(stream, exampleName); } }
//Save File public void ExportToDocx(RadDocument document) { DocxFormatProvider provider = new DocxFormatProvider(); SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = ".hcx"; saveDialog.Filter = "Documents|*.hcx"; DialogResult dialogResult = saveDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { using (Stream output = saveDialog.OpenFile()) { provider.Export(document, output); MessageBox.Show("Saved Successfuly!"); } } }
private void SaveFile(RadFlowDocument document) { string path = "Mail Merge Sample.docx"; using (Stream stream = File.OpenWrite(path)) { DocxFormatProvider formatProvder = new DocxFormatProvider(); formatProvder.Export(document, stream); } ProcessStartInfo psi = new ProcessStartInfo() { FileName = path, UseShellExecute = true }; Process.Start(psi); Console.Write("Mail merge finished - the document is saved."); }
private void Save(RadFlowDocument document) { IFormatProvider <RadFlowDocument> formatProvider = new DocxFormatProvider(); string path = "CVTemplate.docx"; using (FileStream stream = File.OpenWrite(path)) { formatProvider.Export(document, stream); } Console.WriteLine("Document generated."); ProcessStartInfo psi = new ProcessStartInfo() { FileName = path, UseShellExecute = true }; Process.Start(psi); }
public static void Export(this RadGridView grid, ExportSettings settings) { var dialog = new SaveFileDialog(); switch (settings.Format) { case ExportFormat.Pdf: dialog.DefaultExt = "*.pdf"; dialog.Filter = "Adobe PDF 文档 (*.pdf)|*.pdf"; break; case ExportFormat.Excel: dialog.DefaultExt = "*.xlsx"; dialog.Filter = "Excel 工作簿 (*.xlsx)|*.xlsx"; break; case ExportFormat.Word: dialog.DefaultExt = "*.docx"; dialog.Filter = "Word 文档 (*.docx)|*.docx"; break; case ExportFormat.Csv: dialog.DefaultExt = "*.csv"; dialog.Filter = "CSV (逗号分隔) (*.csv)|*.csv"; break; } if (settings.FileName != null) { dialog.DefaultFileName = settings.FileName; } if (dialog.ShowDialog() == true) { switch (settings.Format) { case ExportFormat.Csv: using (var output = dialog.OpenFile()) { grid.Export(output, new GridViewExportOptions { Format = Telerik.Windows.Controls.ExportFormat.Csv, ShowColumnFooters = grid.ShowColumnFooters, ShowColumnHeaders = grid.ShowColumnHeaders, ShowGroupFooters = grid.ShowGroupFooters }); } break; case ExportFormat.Excel: { var workbook = CreateWorkBook(grid); if (workbook != null) { var provider = new XlsxFormatProvider(); using (var output = dialog.OpenFile()) { provider.Export(workbook, output); } } } break; default: { var document = CreateDocument(grid, settings); if (document != null) { document.LayoutMode = DocumentLayoutMode.Paged; document.Measure(RadDocument.MAX_DOCUMENT_SIZE); document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize)); IDocumentFormatProvider provider = null; switch (settings.Format) { case ExportFormat.Pdf: provider = new PdfFormatProvider(); break; case ExportFormat.Word: provider = new DocxFormatProvider(); break; } using (var output = dialog.OpenFile()) { if (provider != null) provider.Export(document, output); } } } break; } } }
public byte[] BuildReport(DataCell[,] pitsDesc, DataCell[,] labDataGrid, DataCell[,] fieldDataGrid, string mapImageUrl, List <string> attachedFiles) { ReportDataSource reportDataSource = new ReportDataSource(); m_Document = m_Document.MailMerge(new List <ReportDataSource>() { reportDataSource }); Section section = m_Document.Sections[0]; if (pitsDesc != null) { AddNewHeader(section, "תיאור ממצאי הסקר"); List <Table> pitDataTables = new TableBuilder(pitsDesc).Resolve(m_Document, 0, 100); foreach (Table table in pitDataTables) { section.Blocks.Add(table); section.Blocks.Add(new Paragraph(m_Document)); } } if (labDataGrid != null) { AddNewHeader(section, "תוצאות בדיקת מעבדה"); List <Table> labDataTables = new TableBuilder(labDataGrid).Resolve(m_Document, Convert.ToInt32(ConfigurationManager.AppSettings["labDataRepeaters"]), Convert.ToInt32(ConfigurationManager.AppSettings["tableMax"])); foreach (Table table in labDataTables) { section.Blocks.Add(table); section.Blocks.Add(new Paragraph(m_Document)); } } if (fieldDataGrid != null) { AddNewHeader(section, "תוצאות נתוני שטח"); List <Table> fieldDataTables = new TableBuilder(fieldDataGrid).Resolve(m_Document, Convert.ToInt32(ConfigurationManager.AppSettings["fieldDataRepeaters"]), Convert.ToInt32(ConfigurationManager.AppSettings["tableMax"])); foreach (Table table in fieldDataTables) { section.Blocks.Add(table); section.Blocks.Add(new Paragraph(m_Document)); } } if (mapImageUrl != null) { AddNewHeader(section, "מפה"); CreateImage(mapImageUrl, section); section.Blocks.Add(new Paragraph(m_Document)); } if (attachedFiles != null) { AddNewHeader(section, "קבצים מקושרים"); foreach (string attachedFileUrl in attachedFiles) { CreateImage(attachedFileUrl, section); section.Blocks.Add(new Paragraph(m_Document)); } } DocxFormatProvider formatProvider = new DocxFormatProvider(); byte[] renderedBytes = null; using (MemoryStream ms = new MemoryStream()) { formatProvider.Export(m_Document, ms); renderedBytes = ms.ToArray(); } return(renderedBytes); }
private void SaveFile(RadFlowDocument document) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Docx File (*.docx)|*.docx"; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { DocxFormatProvider formatProvder = new DocxFormatProvider(); formatProvder.Export(document, stream); } } }