New to Telerik Document Processing? Download free 30-day trial

Convert Xlsx to PDF

Product Version Product Author
2021.2.511 RadSpreadProcessing Dimitar Karamfilov

Description

This article demonstrates how you can convert a Xlsx file to a PDF with the SpreadProcessing library.

Solution

The solution is to import the file with the XlsxFormatProvider and export it with the PdfFormatProvider.

Convert Xlsx to PDF

public static void ConvertXlsxToPdf(string path, string resultPath) 
{ 
    var xlsxProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider(); 
    var pdfProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider(); 
 
    var docBytes = File.ReadAllBytes(path); 
    var workbook = xlsxProvider.Import(docBytes); 
 
    var resultBytes = pdfProvider.Export(workbook); 
    File.WriteAllBytes(resultPath, resultBytes); 
} 
In this article