# AI-Assisted Formula Generation and Explanation

## Content

The ​**​SpreadJS AI Add-on​**​ enhances the [Formula Eidtor Panel](/spreadjs/docs/v18/features/formulas/formula-editor-panel) with AI-powered features, allowing users to:

* ​**​Generate Excel formulas​**​ using natural language.
* ​**​Explain existing formulas​**​ with step-by-step breakdowns.

These features leverage the current worksheet’s data context for accurate and intelligent formula suggestions.

> To use this feature, you first need to configure the AI Add-on for SpreadJS, refer to [AI Assistant](/spreadjs/docs/v18/features/ai-assistant)

## **User Guide​**

### **Opening the AI Assistant​**

* Click the ​**​AI button​**​ in the ​**​Formula Editor Panel​**​ to launch the assistant.

 ![image](https://cdn.mescius.io/document-site-files/images/7719ad0a-f083-46d7-aff6-f63e2e187c15/image.f1bb84.png?width=401)

### **Generating a Formula​**

1. ​​Describe your formula need​​ in plain language (e.g., *"Calculate the average of values in Column A"*).
2. Press ​​**Enter**​​ or click ​​**Send**​​ to submit.
    * Use ​​**Shift + Enter**​​ for multi-line input.
3. The AI-generated formula will appear in the ​​Formula Editor Panel​​, formatted for readability.
4. Click ​​Apply​​ to insert the formula into the active cell.
5. Click ​​Close​​ to exit the assistant.

 ![image](https://cdn.mescius.io/document-site-files/images/7719ad0a-f083-46d7-aff6-f63e2e187c15/image.9b2b61.png?width=800)

> 1\. Provide specific details \(e\.g\.\, cell ranges and conditions\) for better accuracy\.
> 2\. Test the formula with sample data to verify its correctness\.
> 3\. Different AI models have different capabilities\, so the results they return may also vary\.

### **Explaining a Formula​**

1. Enter or paste an existing formula into the ​**​Formula Editor Panel​**​.
2. Click the ​**​Query​**​ button to receive a breakdown, may including:
    * Formula Meaning
    * Formula Breakdown
    * ​​Function & arguments​​ explanation.
    * Explain with Context
3. If you're not satisfied with the generated results, click the refresh button to regenerate them.

 ![image](https://cdn.mescius.io/document-site-files/images/7719ad0a-f083-46d7-aff6-f63e2e187c15/image.31c0e6.png?width=350)

## Best Practices

* **Generating complex formulas**: Describe your requirements step by step (for example, filter first, then sum).
* **Debugging formulas**: Use the "Explain" feature to verify the correctness of your formula's logic.
* **Learning tool**: Learn how to use functions through AI-generated formulas and explanations.

> This feature relies on a network connection to call AI services.
> After generating formulas, it's recommended to manually check the data ranges and logic to ensure they meet your expectations.