.NET Excel Layout-Add Excel Background Image in C# and Visual Basic

Each company must have a lot of reports to present monthly sales, financial situation etc. And these reports are often released with a great appearance and layout, for example, well-designed cells or with beautiful charts. If we want to create a wonderful report, how to do?

As is known, Excel is very powerful on displaying, editing and calculating data information so that it was recognized as one of the best choice to create report. Now, the data information has been imported to Excel and next we need to format this Excel to be a appealed one. In this post, I will introduce a solution to make an Excel attractive through adding background image in C# and Visual Basic.

In this example, a .NET Excel component  is used so that I have added its dll as reference in my project.

Firstly, load this Excel file and initialize a Worksheet instance. Secondly, get a Bitmap image instance from specified path. Thirdly, assign this image instance as value for BackgroundImage property of PageSetup of this sheet instance. Finally, save the new Excel file and launch for viewing.

Please follow the code below to insert Excel background image.



using System.Drawing;

using Spire.Xls;


namespace ExcelBackgroundImage


    class Background


        static void Main(string[] args)


            //Load File

            Workbook workbook = new Workbook();


            Worksheet sheet = workbook.Worksheets[0];


            //Set Background Image

            Bitmap bm = new Bitmap(Image.FromFile(@”E:\Work\Documents\SampleImage\X.jpg”));

            sheet.PageSetup.BackgoundImage = bm;


            //Save and Launch

            workbook.SaveToFile(“Background.xlsx”, ExcelVersion.Version2010);







Imports System.Drawing

Imports Spire.Xls


Namespace ExcelBackgroundImage

    Friend Class Background

        Shared Sub Main(ByVal args() As String)

            ‘Load File

            Dim workbook As New Workbook()


            Dim sheet As Worksheet = workbook.Worksheets(0)


            ‘Set Background Image

            Dim bm As New Bitmap(Image.FromFile(“E:\Work\Documents\SampleImage\X.jpg”))

            sheet.PageSetup.BackgoundImage = bm


            ‘Save and Launch

            workbook.SaveToFile(“Background.xlsx”, ExcelVersion.Version2010)


        End Sub

    End Class

End Namespace



DOWNLOAD Spire.XLS for .NET Here


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s