4 Simple Steps to Create Thumbnail Images for Excel Documents in C#
Tags: fileformats, csharp, excel
Published: 2023-08-03 15:11:21

---
title: 4 Simple Steps to Create Thumbnail Images for Excel Documents in C#
published: true
date: 2023-08-03 10:34:16 UTC
tags: fileformats, csharp, excel
canonical_url: https://www.syncfusion.com/blogs/post/excel-to-thumbnail-conversion-csharp.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0phbo842rrrqvm0ad3l7.png
---
In today’s digital age, visual representation is crucial in capturing attention and conveying information effectively. Whether working on a personal project or developing professional software, creating visually appealing thumbnail images can significantly enhance the user experience and facilitate more straightforward navigation.

This article will show you how to [create a thumbnail image for an Excel](https://help.syncfusion.com/file-formats/xlsio/worksheet-to-image-conversion "Worksheet to image conversion in .NET Excel Library") document using the [Syncfusion .NET Core Excel (XlsIO) Library](https://www.syncfusion.com/document-processing/excel-framework/net-core/excel-library ".NET Excel Library") in C#.

## Creating thumbnail images for Excel documents using C#

Follow these steps to create a thumbnail image for an Excel document using the Syncfusion .NET Excel Library:

**Note:** If you are new to our Excel Library, our [Getting Started guide](https://help.syncfusion.com/file-formats/xlsio/getting-started-create-excel-file-csharp-vbnet "Getting Started - Create Excel File in C# and VB.NET") is highly recommended.

1.First, open [Visual Studio](https://visualstudio.microsoft.com/downloads/ "Visual Studio") and create a new .NET Core console application. ![Create a .NET Core console application](https://www.syncfusion.com/blogs/wp-content/uploads/2023/08/Create-a-console-application-in-.NET-Core.png)
2.Then, install the latest version of the [Syncfusion.XlsIORenderer.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIORenderer.Net.Core "Syncfusion.XlsIO.Net.Core NuGet package") NuGet package. ![Install the Syncfusion.XlsIORenderer.Net.Core NuGet package](https://www.syncfusion.com/blogs/wp-content/uploads/2023/08/Install-the-Syncfusion.XlsIORenderer.Net_.Core-Nuget-package..png)
3.Add the following code to the **Program.cs** file to convert an Excel document to an image.
```csharp
using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;
    FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(inputStream);
    IWorksheet sheet = workbook.Worksheets[0];
    
    //Initialize XlsIORenderer.
    application.XlsIORenderer = new XlsIORenderer();
    
    //Convert to image.
    MemoryStream outputStream = new MemoryStream();
    sheet.ConvertToImage(sheet.UsedRange, outputStream);
}
```
4.Then, add the following code to resize the image to thumbnail size.
```csharp
//Resize image to thumbnail size.
System.Drawing.Image image = System.Drawing.Image.FromStream(outputStream);
System.Drawing.Image thumbnail = image.GetThumbnailImage(100, 100, () => false, IntPtr.Zero);

//Save image.
thumbnail.Save("Image.png", System.Drawing.Imaging.ImageFormat.Png);
```
Following is the complete code of the **Program.cs** file.
```csharp
using System;
using System.IO;
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;

namespace Excel_to_Image
{
    internal class Program
    {
        static void Main(string[] args)
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Xlsx;
                FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
                IWorkbook workbook = application.Workbooks.Open(inputStream);
                IWorksheet sheet = workbook.Worksheets[0];
                
                //Initialize XlsIORenderer.
                application.XlsIORenderer = new XlsIORenderer();
                
                //Convert to image.
                MemoryStream outputStream = new MemoryStream();
                sheet.ConvertToImage(sheet.UsedRange, outputStream);
                
                //Resize image to thumbnail size.
                System.Drawing.Image image = System.Drawing.Image.FromStream(outputStream);
                System.Drawing.Image thumbnail = image.GetThumbnailImage(100, 100, () => false, IntPtr.Zero);
                
                //Save the image.
                thumbnail.Save("Image.png", System.Drawing.Imaging.ImageFormat.Png);
            }
            
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo = new System.Diagnostics.ProcessStartInfo("Image.png")
            {
                UseShellExecute = true
            };
            process.Start();
        }
    }
}
```
Refer to the following images.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/08/Input-Excel-document.png" alt="Input Excel document" style="width:100%">

  <figcaption>Input Excel document</figcaption>

</figure>
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/08/Thumbnail-image-for-the-input-Excel-document.png" alt="Thumbnail image for the input Excel document" style="width:100%">

  <figcaption>Thumbnail image for the input Excel document</figcaption>

</figure>

## GitHub reference

You can download the example for creating thumbnail images for Excel documents on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Real%20Time%20Examples%20in%20Excel/Excel%20To%20Thumbnail%20Image "Excel To thumbnail image conversion GitHub demo").

## Conclusion

Thanks for reading! In this blog, we’ve seen how to create thumbnail images for Excel documents using the [Syncfusion .NET Core Excel Library](https://www.syncfusion.com/document-processing/excel-framework/net-core/excel-library ".NET Core Excel Library") in C#. Take a moment to peruse the [documentation](https://help.syncfusion.com/file-formats/xlsio/overview "Getting started with Excel Library"), where you’ll find other features with accompanying code samples.

Using this library, you can also export Excel data to [PDF](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion "Excel to PDF conversion"),  [data tables](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table "Exporting from Worksheet to Data Table"), [CSV](https://www.syncfusion.com/kb/9092/convert-excel-file-to-csv-in-c-vb-net "Converting Excel files to CSV"), [TSV](https://www.syncfusion.com/kb/8556/does-xlsio-support-tsv-files "Excel to TSV files conversion"), [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-worksheet#save-worksheet-as-html "Saving Worksheet as HTML"), [collections of objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-collection-objects "Exporting from Worksheet to Collection Objects"), [ODS](https://help.syncfusion.com/file-formats/xlsio/excel-to-ods-conversion "Convert Excel to ODS"), [JSON](https://help.syncfusion.com/file-formats/xlsio/excel-to-json-conversion "Excel to JSON conversion"), and other file formats.

Are you already a Syncfusion subscriber? You can download the product setup [here](https://www.syncfusion.com/account/downloads/studio/ "Essential Studio License and Downloads page"). If you’re not a Syncfusion subscriber, you can download a [free 30-day trial](https://www.syncfusion.com/downloads/fileformats/confirm "Get the free evaluation of the Essential Studio for File Formats") to check out Essential Studio’s features.

Please let us know in the comments section below if you have any questions about these features. You can also contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion Support Forum"), [support portal](https://support.syncfusion.com "Syncfusion Support Portal"), or [feedback portal](https://www.syncfusion.com/feedback/excel "Syncfusion Feedback Portal"). We are always happy to assist you!

## Related blogs

- [6 Easy Ways to Export Data to Excel in C#](https://www.syncfusion.com/blogs/post/6-easy-ways-to-export-data-to-excel-in-c-sharp.aspx "Blog: 6 Easy Ways to Export Data to Excel in C#")
- [Seamlessly Import and Export CSV Data in Excel Using C#](https://www.syncfusion.com/blogs/post/import-export-csv-data-in-excel-csharp.aspx "Blog: Seamlessly Import and Export CSV Data in Excel Using C#")
- [How to Export Data from SQL Server to Excel Tables in C#](https://www.syncfusion.com/blogs/post/export-data-from-sql-server-to-excel-in-c-sharp.aspx "Blog: How to Export Data from SQL Server to Excel Tables in C#")
- [Export Data from Collections to Excel and Group It in C#](https://www.syncfusion.com/blogs/post/export-data-from-collection-to-excel-and-group-csharp.aspx "Blog: Export Data from Collections to Excel and Group It in C#")
- [Export Data to a Predefined Excel Template in C#](https://www.syncfusion.com/blogs/post/export-data-to-a-predefined-excel-template-in-c.aspx "Blog: Export Data to a Predefined Excel Template in C#")
- [Easy Steps to Export HTML Tables to Excel in C#](https://www.syncfusion.com/blogs/post/easy-steps-to-export-html-tables-to-an-excel-worksheet-in-c.aspx "Blog: Easy Steps to Export HTML Tables to Excel in C#")