Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to Add Cell Fill in Excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-02-2011
peterjack
 
Posts: n/a
ThumbsUp How to Add Cell Fill in Excel
  

What's Cell Fill in Excel?
Cell fill is indeed the colors and patterns of the cell. The content in the cell could have many kinds of colors and patterns. It will be better to get good colors and patterns. The cell fill could give Excel a good appearance. And in fact there are three ways: you can choose the color; you can choose the pattern; you can choose both of them. The better choice will make Excel look better and have good impressions for others.
How to Add Cell Fill in Microsoft Excel?
It is easy to add cell fill to Excel with Microsoft Excel. Once you have entered the content to the cell. You can select the format on the menu. Then select cell ->pattern. And now you can find there are many kinds of colors and patterns on the diaglog box. You can choose the colors and patterns which you need for your cell.
Add Cell Fill via Spire.XLS.
In Spire.XLS, you can use sheet.Range["A1"].Style.Color method to set the color of the cell. While using sheet.Range["A1"].Style.FillPattern, you can set the filled pattern of the cell. I will show you the way of cell fill below. In the end of the code, I give you the example of setting the color and pattern filled together.
The following code is about C# cell fill:
[C#]
using System.Drawing;
using Spire.Xls;

namespace Hyperlink
{
class Program
{
static void Main(string[] args)
{
//Create a new workbook.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

//Write a common text.
sheet.Range["B2"].Text = "Home page";

//Write a text with background color.
sheet.Range["B4"].Text = "Home page";
sheet.Range["B4"].Style.Color = Color.Green;

//Write a text to the cell with pattern filled in.
sheet.Range["B6"].Text = "Home page";
sheet.Range["B6"].Style.FillPattern = ExcelPatternType.Percent125Gray;

//Write a text with background color and pattern filled in.
sheet.Range["B8"].Text = "Home page";
sheet.Range["B8"].Style.Color = Color.Green;
sheet.Range["B8"].Style.FillPattern = ExcelPatternType.Percent125Gray;
sheet.AutoFitColumn(2);

//Save the file.
workbook.SaveToFile("Sample.xls");

//Launch the file.
System.Diagnostics.Process.Start("Sample.xls");
}
}
}

The following code is about VB.NET cell fill:
[Visual Basic]
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports Spire.Xls

Module Module1

Sub Main()
'Create a new workbook.
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)

'Write a common text.
sheet.Range["B2"].Text = "Home page";

'Write a text with background color.
sheet.Range["B4"].Text = "Home page";
sheet.Range["B4"].Style.Color = Color.Green;

'Write a text to the cell with pattern filled in.
sheet.Range["B6"].Text = "Home page";
sheet.Range["B6"].Style.FillPattern = ExcelPatternType.Percent125Gray;

'Write a text with background color and pattern filled in.
sheet.Range["B8"].Text = "Home page";
sheet.Range["B8"].Style.Color = Color.Green;
sheet.Range["B8"].Style.FillPattern = ExcelPatternType.Percent125Gray;
sheet.AutoFitColumn(2);

'Save the file.
workbook.SaveToFile("Sample.xls")

'Launch the file.
System.Diagnostics.Process.Start("Sample.xls")
End Sub
End Module


Last edited by Kunal : 08-02-2011 at 02:23 PM. Reason: External Linking is not allowed
Reply With Quote
  #2  
Old 09-02-2011
Member
 
Join Date: Mar 2010
Posts: 190
Re: How to Add Cell Fill in Excel

Hey, thank you so much for providing such a nice explanation for the cell fill in Excel. I was also searching for the same from few days and was not able to get the proper answer for this but this is really helpful to me and I am sure that other users will also be able to understand that with help of this. Thank you so much.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Add Cell Fill in Excel"
Thread Thread Starter Forum Replies Last Post
Applying absolute cell referencing to many cell in Excel Nyota MS Office Support 2 24-02-2012 06:23 PM
How to fill only half part of cell in Microsoft Excel Roch MS Office Support 3 28-01-2012 03:01 PM
How to fill color in to the Row of Microsoft Excel Shaina Na MS Office Support 6 14-01-2012 12:29 PM
How to restore cell gridlines lost after coloring the cell in Excel? Chitti's Windows Software 2 04-01-2012 05:54 PM
Excel 2000 - Change Default Cell Fill Color Cris Han MS Office Support 2 20-02-2008 08:29 PM


All times are GMT +5.5. The time now is 10:01 PM.