IronXL How-Tos Background Pattern & Color How to Set Cell Background Pattern & Color ByChaknith Bin August 1, 2023 Updated June 22, 2025 Share: In Excel, a background cell pattern refers to the visual design or fill applied to a cell's background. Additionally, background cell color refers to the solid color applied to a cell's background.By combining both features, users can create visually appealing cell backgrounds with a wide range of pattern styles, colors, and textures. With IronXL, you can leverage these features to customize cell backgrounds in Excel, enhancing data visualization and highlighting important information in your spreadsheets. View the IronXL YouTube Playlist How to Set Cell Background Pattern & Color Download the C# library to set background pattern and color Open an existing or create a new Excel spreadsheet Set the FillPattern property of the cell, column, row, or range to define the fill pattern Use the SetBackgroundColor method to set the color Export all available fill patterns Get started with IronXL Start using IronXL in your project today with a free trial. First Step: Start for Free Set Cell Background Pattern & Color Example To set a background pattern for a selected cell, column, row, or range, use the FillPattern property with one of the enums from IronXL.Styles.FillPattern. Then, utilize the SetBackgroundColor method or set the BackgroundColor property to apply the desired color. You can choose the color from the Color class or input the Hex color code. For example, SeaGreen is "#FFF5EE". Please noteit is currently not possible to change the color of the fill pattern. :path=/static-assets/excel/content-code-examples/how-to/background-pattern-color-set-background-pattern-color.cs using IronXL; using IronXL.Styles; using IronSoftware.Drawing; // Create a new Excel workbook WorkBook workBook = WorkBook.Create(); // Retrieve the default worksheet from the workbook WorkSheet workSheet = workBook.DefaultWorkSheet; // Set background pattern for cell A1 workSheet["A1"].Style.FillPattern = FillPattern.AlternateBars; // Set background color of cell A1 using a predefined Color object workSheet["A1"].Style.SetBackgroundColor(Color.Aquamarine); // Set background pattern for cell A2 workSheet["A2"].Style.FillPattern = FillPattern.ThickVerticalBands; // Set background color of cell A2 using a hex color string workSheet["A2"].Style.SetBackgroundColor("#ADFF2F"); // Save the workbook to a file with the specified filename workBook.SaveAs("setBackgroundPattern.xlsx"); Imports IronXL Imports IronXL.Styles Imports IronSoftware.Drawing ' Create a new Excel workbook Private workBook As WorkBook = WorkBook.Create() ' Retrieve the default worksheet from the workbook Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Set background pattern for cell A1 Private workSheet("A1").Style.FillPattern = FillPattern.AlternateBars ' Set background color of cell A1 using a predefined Color object workSheet("A1").Style.SetBackgroundColor(Color.Aquamarine) ' Set background pattern for cell A2 workSheet("A2").Style.FillPattern = FillPattern.ThickVerticalBands ' Set background color of cell A2 using a hex color string workSheet("A2").Style.SetBackgroundColor("#ADFF2F") ' Save the workbook to a file with the specified filename workBook.SaveAs("setBackgroundPattern.xlsx") $vbLabelText $csharpLabel Available Fill Patterns Utilize the available fill patterns from the IronXL.Styles.FillPattern enum to set the desired fill pattern in your Excel sheets. Below is an illustration showcasing all the available fill patterns offered by IronXL: Frequently Asked Questions What is a cell background pattern in Excel? In Excel, a background cell pattern refers to the visual design or fill applied to a cell's background, allowing for various styles, colors, and textures. How can I set a cell background color in Excel with a C# library? You can set a cell background color by using the `SetBackgroundColor` method or setting the `BackgroundColor` property of a cell, column, row, or range in IronXL. Which method is used to apply a fill pattern to a cell in a C# library? To apply a fill pattern, you can set the `FillPattern` property of the cell, column, row, or range using one of the enums from `IronXL.Styles.FillPattern`. Can I use Hex color codes to set background colors with a C# library? Yes, you can use Hex color codes or select from the predefined colors in the `Color` class to set background colors in IronXL. Is it possible to change the color of the fill pattern itself in a C# library? No, it is currently not possible to change the color of the fill pattern itself in IronXL. What libraries do I need to import to handle colors in a C# library? You need to import the IronXL, IronXL.Styles, and System.Drawing namespaces to handle colors in IronXL. How do I get started with a C# library to customize Excel sheets? To get started with IronXL, download the C# library from NuGet, open an existing or create a new Excel spreadsheet, and then use the provided methods to customize the cell appearances. What are the available fill patterns in a C# library? IronXL offers a variety of fill patterns that can be accessed using the `IronXL.Styles.FillPattern` enum. These patterns can be applied to cells to enhance the visual appeal of Excel sheets. Chaknith Bin Chat with engineering team now Software Engineer Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking. Ready to Get Started? Free NuGet Download Total downloads: 1,446,926 View Licenses