Class FillFormat

FillFormat class

Encapsulates the object that represents fill formatting for a shape.

public class FillFormat

Properties

NameDescription
FillType { get; set; }Gets and sets fill type
GradientColor1 { get; }Returns the gradient color 1 for the specified fill.
GradientColor2 { get; }Returns the gradient color 2 for the specified fill.
GradientColorType { get; }Returns the gradient color type for the specified fill.
GradientDegree { get; }Returns the gradient degree for the specified fill. Only applies for Excel 2007.
GradientFill { get; }Gets GradientFill object.
GradientStyle { get; }Returns the gradient style for the specified fill.
GradientVariant { get; }Returns the gradient variant for the specified fill. Only applies for Excel 2007.
ImageData { get; set; }Gets and sets the picture image data.
Pattern { get; set; }Represents an area’s display pattern.
PatternFill { get; }Gets PatternFill object.
PictureFormatType { get; set; }Gets and sets the picture format type.
PresetColor { get; }Returns the gradient preset color for the specified fill.
Scale { get; set; }Gets and sets the picture format scale.
SetType { get; set; }(Obsolete.) Gets the fill format set type.
SolidFill { get; }Gets SolidFill object.
Texture { get; set; }Represents the texture type for the specified fill.
TextureFill { get; }Gets TextureFill object.
Transparency { get; set; }Returns or sets the degree of transparency of the area as a value from 0.0 (opaque) through 1.0 (clear).
Type { get; set; }(Obsolete.) Gets and sets the fill type.

Methods

NameDescription
override Equals(object)
override GetHashCode()Gets the hash code.
SetOneColorGradient(Color, double, GradientStyleType, int)Sets the specified fill to a one-color gradient. Only applies for Excel 2007.
SetPresetColorGradient(GradientPresetType, GradientStyleType, int)Sets the specified fill to a preset-color gradient. Only applies for Excel 2007.
SetTwoColorGradient(Color, Color, GradientStyleType, int)Sets the specified fill to a two-color gradient. Only applies for Excel 2007.
SetTwoColorGradient(Color, double, Color, double, GradientStyleType, int)Sets the specified fill to a two-color gradient. Only applies for Excel 2007.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Drawing;
using System.Drawing;

namespace AsposeCellsExamples
{
    public class DrawingClassFillFormatDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access the first worksheet
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Add sample data to cells
            worksheet.Cells["A1"].PutValue(50);
            worksheet.Cells["A2"].PutValue(100);
            worksheet.Cells["A3"].PutValue(150);
            worksheet.Cells["A4"].PutValue(200);
            worksheet.Cells["B1"].PutValue(60);
            worksheet.Cells["B2"].PutValue(32);
            worksheet.Cells["B3"].PutValue(50);
            worksheet.Cells["B4"].PutValue(40);
            worksheet.Cells["C1"].PutValue("Q1");
            worksheet.Cells["C2"].PutValue("Q2");
            worksheet.Cells["C3"].PutValue("Y1");
            worksheet.Cells["C4"].PutValue("Y2");
            
            // Add a column chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
            
            // Add data series to the chart
            int seriesIndex = chart.NSeries.Add("A1:B4", true);
            chart.NSeries.CategoryData = "C1:C4";
            
            // Apply gradient fill to the series area
            chart.NSeries[seriesIndex].Area.FillFormat.SetOneColorGradient(System.Drawing.Color.Lime, 1, 
                GradientStyleType.Horizontal, 1);
            
            // Save the workbook
            workbook.Save("FillFormatDemo.xlsx");
        }
    }
}

See Also