This is a migrated thread and some comments may be shown as answers.

Convert Excel in Pdf

1 Answer 1510 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 1
Mario asked on 07 Sep 2017, 08:59 AM

Hello, I need to export / convert an Excel file to Pdf file.

Unfortunately using Microsoft.Interop everything works in development but not in production.

I have been able to use the RadFlowDocument features to convert a Word file to pdf using the following code.

public void TransformPdf(string fileSource, string fileDestination)
       {
           IFormatProvider<RadFlowDocument> fileFormatProvider = new DocxFormatProvider();
           using (FileStream input = new FileStream(fileSource, FileMode.Open))
           {
               RadFlowDocument document = fileFormatProvider.Import(input);
 
               byte[] renderedBytes = null;
 
               IFormatProvider<RadFlowDocument> formatProvider = new RtfFormatProvider();
               using (MemoryStream ms = new MemoryStream())
               {
                   formatProvider.Export(document, ms);
                   renderedBytes = ms.ToArray();
 
                   File.WriteAllBytes(fileDestination, renderedBytes);
               }
           }
       }

My question is: Do you have a similar or alternative way to make a pdf conversion using the Telerik libraries?

Thank you, Mario

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 07 Sep 2017, 01:37 PM
Hi Mario,

You can achieve that requirement using RadSpreadProcessing. The approach is pretty similar to the one used for RadFlowDocument. You will need to import the spreadsheet document using XslsxFormatProvider and then export it through the PdfFormatProvider class of RadSpreadProcessing.

Hope this is helpful.

Regards,
Tanya
Progress Telerik

Tags
SpreadProcessing
Asked by
Mario
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or