MsoFillFormatHelper.ForeColor
MsoFillFormatHelper.ForeColor property
Gets and sets the fill fore color.
public Color ForeColor { get; set; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Drawing;
using System;
using System.Drawing;
using System.Reflection;
public class MsoFillFormatHelperPropertyForeColorDemo
{
public static void Run()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add a label to make the example meaningful
worksheet.Cells["A1"].Value = "ForeColor Property Demo";
try
{
// Create an instance of MsoFillFormatHelper using reflection (no public constructor)
MsoFillFormatHelper fillHelper = (MsoFillFormatHelper)Activator.CreateInstance(
typeof(MsoFillFormatHelper), nonPublic: true);
// Display the default ForeColor value
Console.WriteLine($"Default ForeColor: {fillHelper.ForeColor}");
// Set a new ForeColor value
fillHelper.ForeColor = Color.FromArgb(255, 128, 0, 128); // Purple color
Console.WriteLine($"Updated ForeColor: {fillHelper.ForeColor}");
// Demonstrate getting the ForeColor value
Color currentColor = fillHelper.ForeColor;
Console.WriteLine($"Current ForeColor (RGB): R={currentColor.R}, G={currentColor.G}, B={currentColor.B}");
// Save the workbook to demonstrate successful execution
workbook.Save("ForeColorDemo.xlsx");
Console.WriteLine("ForeColor property demonstration completed successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error during ForeColor demo: {ex.Message}");
}
}
}
}
See Also
- class MsoFillFormatHelper
- namespace Aspose.Cells.Drawing
- assembly Aspose.Cells