Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export FlowDocument to DOC(x) or XLS

In my program I generate some reports in FlowDocument and display it with DocumentViewer control. Now I need to add more export opportunities. I use iTextSharp to export in PDF, and I can save to XPS natively. Can I save a document directly to any office formats, DOC or XLS. Or maybe someone knows of a good library for converting from PDF / XPS in DOC or XLS?

like image 637
ArtFeel Avatar asked Jul 26 '11 08:07

ArtFeel


2 Answers

I found a solution. As I can't export to Doc from WPF automatically, I reproduced my page layout with DocX Library. This is really awesome and simple library that don't required MSOffice installed to create Word 2007/2010 files.

like image 180
ArtFeel Avatar answered Nov 05 '22 04:11

ArtFeel


I'm not sure if you're looking for an answer, so I'll be brief. You can use the Microsoft Interop assemblies to create Word documents. It's no menial task, but in my opinion, it's easier than using iTextSharp. They come with Visual Studio.

To create XPS documents, you'll need to generate FixedDocument objects from your FlowDocument, but from there, it's only a few lines of code. Eric Sink has a nice article that you can find here. This is also mentioned in this question posted here.

like image 40
Sheridan Avatar answered Nov 05 '22 04:11

Sheridan