Close





 
Excel background color is very useful for developers to design data information. Spire.XLS enables developers to use C#/VB.NET to set Excel color. By using Spire.XLS, developers can set Excel background color through excel cell color. Now, Download Spire.XLS for .NET (or Spire.Office) and install on your system. Follow the simple steps below to set Excel background color.

Step 1 Create Project

Create a project in your visual studio. Both C# and VB.NET are OK. Add Spire.XLS dll as reference.

Step 2 Load Excel File

Load Excel file which we need set cell background color. Use the following code to load the Excel file from local PC.

C# Code:
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\..\..\Data\country.xls",ExcelVersion.Version97to2003);
            Worksheet worksheet = workbook.Worksheets[0];
          

VB.NET Code:
			Dim workbook As New Workbook()
			workbook.LoadFromFile("..\..\..\..\Data\country.xls", ExcelVersion.Version97to2003)
			Dim worksheet As Worksheet = workbook.Worksheets(0)
          

Step 3 Set Excel Background Color

Spire.XLS offers easy solution to set cell background color. By using Spire.XLS, developers/programmers can choose any cells even area to add background color. The code below shows how to set Excel cell background code on 2 different areas.
C# Code:
            //set the backgroundcolor=LighrBlue of Range["A2:E9"]
            worksheet.Range["A2:E9"].Style.Color = Color.LightBlue;

            //set the backgroundcolor=Silver of Range["A11:E18"]
            worksheet.Range["A11:E18"].Style.Color = Color.Silver;
          

VB.NET Code:
			'set the backgroundcolor=LighrBlue of Range["A2:E9"]
			worksheet.Range("A2:E9").Style.Color = Color.LightBlue

			'set the backgroundcolor=Silver of Range["A11:E18"]
			worksheet.Range("A11:E18").Style.Color = Color.Silver
          

Step 4 Save and Preview

After finish the whole simple setting part job, use the following code to save and preview.
C# Code:
            workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003);
            System.Diagnostics.Process.Start(workbook.FileName);
          

VB.NET Code:
workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003)
			System.Diagnostics.Process.Start(workbook.FileName)
          


Effective Screenshot


Spire.XLS allows user to operate Excel document directly such as save to stream, save as web response, copy, lock/unlock worksheet, set up workbook properties, etc. As a professional .NET/Silverlight Excel component, it owns the ability of inserting content into Excel document, formatting cells and converting Excel documents to popular office file formats. Spire.XLS for .NET supports Excel 97-2003, Excel 2007 and Excel 2010. Click to learn more...



Download Spire.XLS
Purchase Spire.XLS
Friday, 13 January 2012 03:11

Merge PDF Documents in Silverlight

Written by support iceblue

The sample demonstrates how to Merge PDF documents in Silverlight via Spire.XLS.

(No Screenshots)

The sample demonstrates how to create Excel group in Silverlight via Spire.XLS.

<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>
Page 1 of 40