GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

Convert Excel files to PDF in C# and VB.NET

The following example demonstrates how to convert Excel files from one format to another in C# and VB.NET.

You can load any Excel file format (XLS, XLSX, ODS, HTML, CSV, TAB, or TXT) and convert it into any other Excel file format (XLS, XLSX, ODS, HTML, CSV, TAB, or TXT). You can also convert it to PDF, XPS, or image format.

Note that below you have Run options with which you can upload your own input Excel file or download the current input file and verify if the conversion to PDF file is satisfactory.

Screenshot
Convert Excel to PDF Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using GemBox.Spreadsheet;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        ExcelFile ef = ExcelFile.Load("ComplexTemplate.xlsx");

        // In order to achieve the conversion of a loaded Excel file to PDF,
        // or to some other Excel format,
        // we just need to save an ExcelFile object to desired output file format.

        ef.Save("Convert.xlsx");
    }
}
Imports System.Text
Imports System.Drawing
Imports GemBox.Spreadsheet

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        Dim ef As ExcelFile = ExcelFile.Load("ComplexTemplate.xlsx")

        ' In order to achieve the conversion of a loaded Excel file to PDF,
        ' or to some other Excel format,
        ' we just need to save an ExcelFile object to desired output file format.
        ef.Save("Convert.xlsx")

    End Sub

End Module

Check next sample.