Results 1 to 2 of 2

Thread: How to Add Cell Fill in Excel

  1. #1
    peterjack Guest

    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

  2. #2
    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.

Similar Threads

  1. Applying absolute cell referencing to many cell in Excel
    By Nyota in forum MS Office Support
    Replies: 2
    Last Post: 24-02-2012, 06:23 PM
  2. How to fill only half part of cell in Microsoft Excel
    By Roch in forum MS Office Support
    Replies: 3
    Last Post: 28-01-2012, 03:01 PM
  3. How to fill color in to the Row of Microsoft Excel
    By Shaina Na in forum MS Office Support
    Replies: 6
    Last Post: 14-01-2012, 12:29 PM
  4. Replies: 2
    Last Post: 04-01-2012, 05:54 PM
  5. Excel 2000 - Change Default Cell Fill Color
    By Cris Han in forum MS Office Support
    Replies: 2
    Last Post: 20-02-2008, 08:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •