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.
static void Main(string args)
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets;
//Set Background Image
Bitmap bm = new Bitmap(Image.FromFile(@”E:\Work\Documents\SampleImage\X.jpg”));
sheet.PageSetup.BackgoundImage = bm;
//Save and Launch
Friend Class Background
Shared Sub Main(ByVal args() As String)
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