How to export data from XLS spreadsheet to PDF file in C# with Spreadsheet SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to export data from XLS spreadsheet to PDF file in C# with Spreadsheet SDK

  • Home
  • /
  • Articles
  • /
  • How to export data from XLS spreadsheet to PDF file in C# with Spreadsheet SDK

The sample below shows how to export data from XLS spreadsheet to PDF file in C#. Spreadsheet SDK loads table from Excel file, adds image and saves the result as PDF.

C#

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.Spreadsheet;
using System.Drawing;
using System.IO;

namespace XLS2PDF
{
    class Program
    {
        static void Main(string[] args)
        {
            Spreadsheet document = new Spreadsheet();

    // load table from existing XLS file        
    document.LoadFromFile("SimpleReport.xls");

    // add image
    document.Workbook.Worksheets[0].Pictures.Add(0, 5, "image1.jpg");

    // save as PDF
    if (File.Exists("output.pdf"))
        File.Delete("output.pdf");
    document.SaveAsPDF("Output.pdf");

    // save as XLS
    if (File.Exists("Output.xls"))
        File.Delete("Output.xls");
    document.SaveAsXLS("Output.xls");

            // close the document 
            document.Close();

        }
    }
}

Tutorials:

prev
next