Articles in this section
Category / Section

How to create WPF Excel comment with background image in C#, VB.NET?

3 mins read

Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Also, converts Excel documents to PDF files. Using this library, you can create Excel comment with background image.

What is the use of comment?

Comments are used to add notes to individual cells which helps reader with additional content for the data it contains. When a cell has a comment, a red triangle indicator appears in the upper-right corner of the cell. When you rest the pointer on the cell, the comment appears.

Steps to create Excel comment with background image, programmatically:

Step 1: Create a new C# console application project.

Create a new C# console application project.

Create a new C# console application

Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from

Install NuGet package

Install NuGet package

Step 3: Add an image to your project as an embedded resource using the following steps.

  1. In Visual Studio, click the Project menu, and select Add Existing Item. Find and select the image you want to add to your project.

Find and select the image

Find and select the image

  1. In the Solution Explorer window, right-click the image file you just added to your project and select Properties from the popup menu. The Properties tool window appears.

Properties tool window

Properties tool window

  1. In the Properties window, change the Build Action property to Embedded Resource.

Adding Embedded Resource

Adding Embedded Resource

  1. Build the project. The image will be compiled into your project’s assembly.

Step 4: Include the following namespace in the Program.cs file.


using Syncfusion.XlsIO;
using System.Drawing;
using System.IO;
using System.Reflection;



Imports Syncfusion.XlsIO
Imports System.Drawing
Imports System.IO
Imports System.Reflection


Step 5: Use the following code snippet to create Excel comment with background image in C#, VB.NET.


using (ExcelEngine excelEngine = new ExcelEngine())
    //Instantiate the Excel application object
    IApplication application = excelEngine.Excel;
    //Add a workbook
    IWorkbook workbook = application.Workbooks.Create(1);
    //Open existing image
    Assembly assembly = typeof(Program).GetTypeInfo().Assembly;
    Stream fileStream = assembly.GetManifestResourceStream("ExcelCommentWithBackgroundImage.Image.PNG");
    //The first worksheet object in the worksheets collection is accessed
    IWorksheet worksheet = workbook.Worksheets[0];
    //Add comment with background image
    worksheet.Range["D5"].AddComment().Text = "Comment With Background Image";
    worksheet.Range["D5"].AddComment().Fill.UserPicture(Image.FromStream(fileStream), "Image.jpg");
    //Save the workbook
    Stream stream = File.Create("Output.xlsx");



Using excelEngine As ExcelEngine = New ExcelEngine()
    ' Instantiate the Excel application object
    Dim application As IApplication = excelEngine.Excel
    ' Add a workbook
    Dim workbook As IWorkbook = application.Workbooks.Create(1)
    'Open existing image
    Dim assembly As Assembly = GetType(Module1).GetTypeInfo.Assembly
    Dim fileStream As Stream = assembly.GetManifestResourceStream("ExcelCommentWithBackgroundImage_VB.Image.PNG")
    'The first worksheet object in the worksheets collection is accessed
    Dim worksheet As IWorksheet = workbook.Worksheets(0)
    'Add comment with background image
    worksheet.Range("D5").AddComment.Text = "Comment With Background Image"
    worksheet.Range("D5").AddComment.Fill.UserPicture(Image.FromStream(fileStream), "Image.PNG")
    'Save the workbook
    Dim stream As Stream = File.Create("Output.xlsx")
End Using


Step 6: Please ensure that System.Drawing.dll is referred to your project.



A complete Windows Forms working example of how to create Excel comment with background image in C# and VB can be downloaded from Create Excel Comment With Background

By executing the program, you will get the output Excel file as shown below.

Output Excel document

Output Excel document

Refer here to explore the rich set of Syncfusion Excel (XlsIO) library features.

See Also:

How to add comments to Excel cell?

How to set RTF text to cell comment using XlsIO?

How to format comments in a cell using XlsIO

How to resize comment box using C#,VB.NET?

How do I insert watermark in MS Excel?

How to set background color for a entire worksheet ?


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


I hope you enjoyed learning how to Create Excel comments with background images in C#, VB.NET.

You can refer to our WPF Excel feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Excel example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment