# Preventing Formula Input in the Spreadsheet

## Environment

<table>
	<tbody>
		<tr>
			<td>Product</td>
			<td>Progress® Kendo UI® Spreadsheet for Angular</td>
		</tr>
	</tbody>
</table>

## Description

I want to prevent users from entering formulas into the cells of the [Kendo UI for Angular Spreadsheet](https://www.telerik.com/kendo-angular-ui/components/spreadsheet) component. How can I achieve this?

This Knowledge Base article also answers the following questions:

* How to prevent formula input in the Kendo UI for Angular Spreadsheet?
* How to block the `=` key in Angular Spreadsheet cells?
* How to restrict users from entering formulas in the Kendo UI for Angular Spreadsheet?

## Solution

To prevent users from entering formulas into the cells of the Spreadsheet:

1. Bind the `changing` event of the [`SpreadsheetWidget`](https://www.telerik.com/kendo-angular-ui/components/spreadsheet/api/spreadsheetwidget) after the view initializes.

   ```ts
   ngAfterViewInit() {
       setTimeout(() => {
           this.spreadsheet.spreadsheetWidget.bind('changing', this.onChanging);
       }, 100);
   }
   ```

2. Use the event arguments to check if the user input starts with `=` and prevent the event.

   ```ts
   private onChanging(args) {
       const data = args.data;

       if (data[0] === '=') {
         args.preventDefault();
         alert('Formulas are not allowed');
       }
   }
   ```

The following example demonstrates the suggested approach in action.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/spreadsheet-prevent-formula-input/source.txt)

## Suggested Links

* [Kendo UI for Angular Spreadsheet Documentation](https://www.telerik.com/kendo-angular-ui/components/spreadsheet)
* [API Reference of the Spreadsheet](https://www.telerik.com/kendo-angular-ui/components/spreadsheet/api/spreadsheetcomponent)
* [Spreadsheet Built-in Formulas](https://www.telerik.com/kendo-angular-ui/components/spreadsheet/built-in-formulas)
* [Spreadsheet Action Bar](https://www.telerik.com/kendo-angular-ui/components/spreadsheet/action-bar)
