# spreadsheet-editor-data-validation

> Spreadsheet editor with data validation feature using gross pay calculation as an example.

**Framework:** vue  **Component:** SpreadsheetEditor  **Variant:** data-validation

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/vue/spreadsheet-editor-data-validation.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-vue-spreadsheet
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/spreadsheet-editor-data-validation/SpreadSheetEditor.vue

```vue
<template>
  <div class="control-section">
    <div id="spreadsheet-validation">
        <ejs-spreadsheet  ref="spreadsheet" :created="created">
            <e-sheets>
                <e-sheet name="Gross Pay">
                    <e-ranges>
                        <e-range :dataSource="dataSource" startCell="A3" ></e-range>
                    </e-ranges>
                    <e-rows>
                        <e-row :cells="cells0"></e-row>
                        <e-row :index="13" :cells="cells12"></e-row>
                    </e-rows>
                    <e-columns>
                    <e-column :width="88"></e-column>
                    <e-column :width="120"></e-column>
                    <e-column :width="106"></e-column>
                    <e-column :width="98"></e-column>
                    <e-column :width="110"></e-column>
                    <e-column :width="110"></e-column>
                    <e-column :width="110"></e-column>
                    <e-column :width="98"></e-column>
                    <e-column :width="130"></e-column>
                    </e-columns>
                </e-sheet>
            </e-sheets>
        </ejs-spreadsheet>
    </div>
  </div>
</template>
<script>
import { SpreadsheetComponent, SheetDirective, RowsDirective, RowDirective, SheetsDirective, ColumnsDirective, ColumnDirective, RangesDirective, RangeDirective } from '@syncfusion/ej2-vue-spreadsheet';
import { grossPay } from '../datasource/spreadsheet-editor-data';

export default {
   components: {
    'ejs-spreadsheet': SpreadsheetComponent,
    'e-sheet': SheetDirective,
    'e-sheets': SheetsDirective,
    'e-row': RowDirective,
    'e-rows': RowsDirective,
    'e-column': ColumnDirective,
    'e-columns': ColumnsDirective,
    'e-range': RangeDirective,
    'e-ranges': RangesDirective
   }, 
   data: () => {
    return {
        dataSource: grossPay,
        cells0: [{  value: 'Gross Pay Calculation', style:{ fontSize: "20pt", fontWeight : "bold", textAlign: "center", backgroundColor: '#B3FFB3', verticalAlign: 'middle'} }],
        cells12: [{ index: 7, value: 'Total Gross', style: { border: '1px solid #A6A6A6', textAlign: 'center', verticalAlign: 'middle', fontWeight:'bold'}},
            {
                index: 8, formula: '=Sum(I4:I13)', format:'$#,##0.00', style: {border: '1px solid #A6A6A6', textAlign: 'center', verticalAlign: 'middle', fontWeight:'bold'}
            }]
    }
  },
  methods: {
    created: function() {
        var spreadsheet = this.$refs.spreadsheet;
        spreadsheet.merge('A1:I2');
        spreadsheet.setBorder({ border: '1px solid #A6A6A6' }, "A1:I13");
        spreadsheet.cellFormat({ textAlign: 'center', verticalAlign: 'middle'}, 'A3:I13');
        spreadsheet.cellFormat({ backgroundColor: '#B3FFB3', fontWeight : "bold"}, 'A3:I3');
        spreadsheet.numberFormat('$#,##0.00', 'H4:I13');
        spreadsheet.numberFormat('m/d/yyyy', 'C4:C13');
        spreadsheet.wrap('H3:I3');
        //Add Data validation to range.
        spreadsheet.addDataValidation({ type: 'WholeNumber', operator: 'LessThan', value1: '9', ignoreBlank: false }, 'G4:G13');
        spreadsheet.addDataValidation({ type: 'TextLength', operator: 'GreaterThan', value1: '3', ignoreBlank: false }, 'B4:B13');
        spreadsheet.addDataValidation({ type: 'Time', operator: 'GreaterThan', value1: '8:00:00 AM', ignoreBlank: false  }, 'E4:E13');
        spreadsheet.addDataValidation({ type: 'Time', operator: 'LessThan', value1: '6:00:00 PM', ignoreBlank: false  }, 'F4:F13');
        spreadsheet.addDataValidation({ type: 'List', value1: 'Mon, Tue, Wed, Thu, Fri', ignoreBlank: false  }, 'D4:D13');
        spreadsheet.addDataValidation({ type: 'WholeNumber', operator: 'LessThan', value1: '=H5', ignoreBlank: false }, 'I4:I13');
        //Highlight Invalid Data.
        spreadsheet.addInvalidHighlight('G4:G13');
        spreadsheet.addInvalidHighlight('I4:I13');
    }
  }
}
</script>
```
