In general, I have a program on WPF, in it I generate reports based on some dynamic data in FlowDocument, and then I display it from using the DocumentViewer control. Now it remains for me to export this report to various formats, with iTextSharp I have the opportunity to save to PDF, and I can also save the document in XPS using native methods.

Tell me how to save FlowDocument in Word, and even better, Excel formats. Or advise libu to C # to convert from PDF / XPS to DOC, I’ve broken the Internet, I find only the reverse conversion from doc to xps, but on the contrary I can’t find anything.

    3 answers 3

    As a result, I made it with the help of the DocX library, a powerful and very simple library, it is much easier to work with it than with Simple OOXML, I recommend!

      Saving from FlowDocument to DOCX and XLSX can be done based on the Open XML SDK 2.0 for Microsoft Office , and specifically with the help of the wrapper library - Simple OOXML .

      Plus Excel can be useful: ExcelPackage and ExcelLibrary .

      • Thanks, I dig it tomorrow, I hope it will help. - ArtFeel 6:09 pm

      I saved in RTF with TextRange.

      TextRange sourceDocument = new TextRange(myFlowDocument.ContentStart, myFlowDocument.ContentEnd); MemoryStream stream = new MemoryStream(); sourceDocument.Save(stream, DataFormats.Rtf); stream.Position = 0; myCreateFileFromStream(fileName, stream); 

      But this is RTF. In RTF, for example, proportional sizes for columns in the table Width = "2 *" do not work.

      Using the DocX library, you re-create the report in DocX and save it in the doc or in the DocX library can you convert from FlowDocument to DocX?

      • If you have a new question, ask it using the " Ask a Question " button. If you need to specify the context, give a link to this question. - Nicolas Chabanovsky ♦
      • With the help of DocX, I created a report and saved it to doc. - ArtFeel
      • Thanks for the answer! Then this option does not suit me - I have a lot of reports and I don’t want to do each report in two versions (in FlowDocument and in DocX). - Nata