Syncfusion Feedback

Convert an Excel Worksheet to an Image with the Syncfusion .NET Excel Library

Video illustration

Watch this video to see how to convert an Excel worksheet to an image using the Syncfusion .NET Excel Library:

Watch the video

Overview

The Syncfusion .NET Excel Library (XlsIO) enables you to create, read, and edit Excel documents programmatically without Microsoft Excel or interop dependencies. Using this library, you can convert an Excel worksheet to an image using C#.

Steps to convert an Excel worksheet to an image

Follow these steps to convert an Excel worksheet to an image using the Syncfusion .NET Excel Library.

Step 1: Create a new project

Start by creating a new C# Console Application project.

Step 2: Install the NuGet package

Add the Syncfusion.XlsIORenderer.Net.Core package to your project from NuGet.org.

Step 3: Include namespaces

Add the following namespaces to your Program.cs file:

using System.IO;
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;

Step 4: Add Excel worksheet-to-image conversion code

Use the following code in the Program.cs file to convert an Excel worksheet to an image.

Run

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;
    FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(inputStream);
    IWorksheet sheet = workbook.Worksheets[0];

    //Initialize XlsIORenderer
    application.XlsIORenderer = new XlsIORenderer();

    #region Save
    //Saving the image.
    FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Image.png"), FileMode.Create, FileAccess.Write);
    sheet.ConvertToImage(sheet.UsedRange, outputStream);
    #endregion

    //Dispose streams.
    outputStream.Dispose();
    inputStream.Dispose();
}

Get started quickly by downloading the installer and and checking license information on the Downloads page.

Syncfusion .NET Excel Library resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.