Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Explain Formula

  • 3 minutes to read

AI-powered “Explain Formula” extension generates a detailed explanation of the formula used in a worksheet cell (clarifying its purpose and function).

Run Demo

#Applies To

Spreadsheet Control

#How It Works

The DevExpress WinForms Spreadsheet control seamlessly integrates the “Explain Formula” extension. When “Explain Formula” is activated, the AI Assistant | Explain Formula command is automatically added to a worksheet cell’s popup menu.

Explain Formula - WinForms Spreadsheet, DevExpress

#Activate Explain Formula

#Install DevExpress NuGet Packages

  1. DevExpress.AIIntegration.WinForms
  2. DevExpress.Win.Design (enables design-time features for DevExpress UI controls)

Read the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:

#Register AI Client

The following code snippet registers the Azure OpenAI client:

using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;

internal static class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        IChatClient asChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
            new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
            .AsChatClient(ModelId);
        AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        // Uncomment the following line if your project targets the .NET Framework and
        // you create AI-powered behaviors in code.
        // DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
        Application.Run(new Form1());
    }
    static string AzureOpenAIEndpoint { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); } }
    static string AzureOpenAIKey { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY"); } }
    static string ModelId { get { return "gpt-4o-mini"; } }
}

Tip

Read the following help topic for additional information: How to Register an AI Client.

#Create and Configure Explain Formula Behavior

  1. Drop the BehaviorManager component from the Toolbox onto a Form.
  2. Add a ExplainFormulaBehavior, configure its settings, and attach the behavior to a DevExpress WinForms Spreadsheet control. You can do this at design time or in code: Create a ExplainFormulaBehavior at Design Time - WinForms Spreadsheet Control, DevExpress

    using DevExpress.AIIntegration.WinForms;
    
     //...
    public SpreadsheetForm() {
        InitializeComponent();
        behaviorManager1.Attach<ExplainFormulaBehavior>(spreadsheetControl1);
    }
    

Tip

Use ExplainFormulaRequest to manually initiate a request to explain the Explain formula:

C#
var response = await defaultAIExtensionsContainer.ExplainFormulaAsync(
    new ExplainFormulaRequest(excelFormula)
);