InsertOptions.FormulaChangeMonitor
InsertOptions.FormulaChangeMonitor property
Gets/sets the monitor for tracking changes caused by the insertion.
public AbstractFormulaChangeMonitor FormulaChangeMonitor { get; set; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
public class InsertOptionsPropertyFormulaChangeMonitorDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add some sample data with formulas
worksheet.Cells["A1"].Value = 10;
worksheet.Cells["A2"].Formula = "=A1*2";
worksheet.Cells["B1"].Formula = "=SUM(A1:A2)";
try
{
// Create InsertOptions instance
InsertOptions options = new InsertOptions();
// Create a custom FormulaChangeMonitor implementation
var monitor = new CustomFormulaChangeMonitor();
options.FormulaChangeMonitor = monitor;
// Display the current FormulaChangeMonitor
Console.WriteLine("FormulaChangeMonitor is set: " +
(options.FormulaChangeMonitor != null));
// Insert rows which may trigger formula changes
worksheet.Cells.InsertRows(1, 1, options);
// Save the result
workbook.Save("FormulaChangeMonitorDemo.xlsx");
Console.WriteLine("FormulaChangeMonitor demonstration completed");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
// Custom implementation of AbstractFormulaChangeMonitor
private class CustomFormulaChangeMonitor : AbstractFormulaChangeMonitor
{
public override void OnCellFormulaChanged(int sheetIndex, int rowIndex, int columnIndex)
{
Console.WriteLine($"Formula changed at Sheet {sheetIndex}, Cell {rowIndex},{columnIndex}");
}
public override void OnFormatConditionFormulaChanged(FormatCondition fc)
{
Console.WriteLine($"Format condition formula changed: {fc.Formula1}");
}
}
}
}
See Also
- class AbstractFormulaChangeMonitor
- class InsertOptions
- namespace Aspose.Cells
- assembly Aspose.Cells