Converting of MS Word reports and Excel spreadsheets to PDF format in C#

Article from our customer

Our organization has a legal department that works with a variety of documents: reports in DOC/DOCX, comparative tables in the XLS/XLSX format and various documents in RTF format.

Our lawyers often need to send these documents to our clients and partners around the world! Edit these documents and make changes is not desirable, and in some cases simply not acceptable!

We’ve decided to convert all of the documentation that is sent by e-mail to PDF. That is, all reports, spreadsheets, reports, etc. have to be converted to PDF and emailed to our partners. To convert DOC/DOCX/XLS/XLSX/RTF to PDF our developers found the UseOffice.Net component from the SautinSoft.

Below there is C# code to convert DOCX/XLSX to PDF:

          SautinSoft.UseOffice converter = new SautinSoft.UseOffice();

string inputFilePath = @"E:\Web\DOC.docx";

string outputFilePath = @"E:\Web\DOC.pdf";

//Prepare UseOffice .Net, loads MS Word in memory

int ret = converter.InitWord();

if (ret==1)


ret = converter.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.DOCX_to_PDF);

//Release MS Word from memory


This is code snippet to export XLSX to PDF:

SautinSoft.UseOffice u = new SautinSoft.UseOffice();

string inputFilePath = @"E:\Excel1.xls";

string outputFilePath = @"E:\Result.pdf";

//Prepare UseOffice .Net, loads MS Excel in memory

int ret = u.InitExcel();

if (ret==1)


ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLS_to_PDF);

//Release MS Excel from memory


If you need a new code example or have a question: email us at or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.