net - export datatable to excel c# windows application without interop

C# Excel Interop-Suppress 'Publishing' dialog when invoking Worksheet.ExportAsFixedFormat (3)

I am using Excel Interop to open an xlsx file and save that as a pdf document. Upon invoking the 'ExportAsFixedFileFormat' method a dialog titled "Publishing" is displayed to indicate the progress. How can I suppress or hide this dialog? I have seen a few similar questions on other forums without a satisfying solution, but hopefully someone has solved this since then.


Application application = new Application();
application.DisplayAlerts = false; // <- No effect
application.Visible = false; // <- No effect
application.ScreenUpdating = false; // <- No effect
application.UserControl = false; // <- No effect
application.Workbooks.Open(path, Type.Missing, true);
application.DisplayDocumentActionTaskPane = false; // <- No effect
application.Worksheets[1].ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, path);

By far the better API to handle (create, read, export to PDF/html, etc...) XLS/XLSX files that I know is FlexCel. It's really simple, incredibly fast and full writen in C#. Don't require Excel instalation.

You'll find it here : (get the trial version with a lot of examples with source code)

If you have budget in your project to acquire the licence, I realy reccomend.

How about processing it on a BackgroundWorker. This will not throw COMEXCEPTION. I tried this code on a button click and it works without displaying the progress dialog.

var worker = new BackgroundWorker();
worker.DoWork += (o, args) =>
    var path = @"D:\sample.xlsx";
    var application = new Microsoft.Office.Interop.Excel.Application();
        Type.Missing, true);
    application.Worksheets[1].ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, path);

You can use pedamorf library ,pedamorf is a server that converts documents, images, urls, html and text to PDF. It relies heavily upon the excellent open-source programs wkhtml2pdf, Libre Office and iTextSharp. A client library is provided and can be used from a .NET application to utilize the conversion services provided by pedamorf.

More info is here