# spreadsheet-editor-parsing-and-serialization

> Spreadsheet editor with parsing and serialization feature to import and export data in various formats.

**Framework:** javascript  **Component:** Spreadsheet  **Variant:** parsing-and-serialization

## 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/javascript/spreadsheet-editor-parsing-and-serialization.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-spreadsheet @syncfusion/ej2-buttons @syncfusion/ej2-dropdowns @syncfusion/ej2-inputs
```

**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-parsing-and-serialization/spreadsheet-editor.html

```html
<div class="col-lg-8 control-section">
    <div id="spreadsheet"></div>
</div>
<div class="col-lg-4 property-section">
    <div class="property">
        <input type="file" id="parse_upload">
        <input type="text" class="input" id="open" style="width: 100%;" />
        <button id="open_button" style="align-self: flex-end; margin-top: 5px; width: 100px;"></button>
    </div>
    <div class="property">
        <input type="text" class="input" id="save" style="width: 100%;" />
        <button id="save_button" style="align-self: flex-end; margin-top: 5px; width: 100px;"></button>
    </div>
</div>
<!-- custom code start -->
<style>
    .control-section .control-wrapper {
        height: calc(100vh - 230px);
        min-height: 550px
    }

    .col-lg-8 {
        width: 70%;
    }

    .col-lg-4 {
        width: 30%;
    }

    .e-ss-uploader .e-file-status {
        display: none !important;
    }

    .property-section {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-top: 20px;
    }

    .property {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        border: 1px solid #a5989887;
        border-radius: 3px;
    }
</style>
<!-- custom code end -->
```

### src/components/spreadsheet-editor-parsing-and-serialization/spreadsheet-editor.ts

```typescript
import { type BeforeOpenEventArgs, type BeforeSaveEventArgs, Spreadsheet } from '@syncfusion/ej2-spreadsheet';
import { Button } from '@syncfusion/ej2-buttons';
import { MultiSelect, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';
import { Uploader } from '@syncfusion/ej2-inputs';
import { defaultData } from '../datasource/spreadsheet-editor-data';
MultiSelect.Inject(CheckBoxSelection);

export function initSpreadsheetEditorParsingAndSerialization(): void {
    let files: any;
    const spreadsheet: Spreadsheet = new Spreadsheet({
        sheets: [
            {
                name: 'Car Sales Report',
                ranges: [{ dataSource: defaultData }],
                rows: [
                    {
                        index: 30,
                        cells: [
                            { index: 4, value: 'Total Amount:', style: { fontWeight: 'bold', textAlign: 'right' } },
                            { formula: '=SUM(F2:F30)', style: { fontWeight: 'bold' } },
                        ]
                    }],
                columns: [
                    { width: 180 }, { width: 130 }, { width: 130 }, { width: 180 },
                    { width: 130 }, { width: 120 }
                ]
            }],
        openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
        saveUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save',

        created: (): void => {
            spreadsheet.cellFormat({ fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' }, 'A1:F1');
            spreadsheet.numberFormat('$#,##0.00', 'F2:F31');
            spreadsheet.numberFormat('m/d/yyyy', 'E2:E30');
        },
        beforeOpen: (args: BeforeOpenEventArgs) => {
            args.parseOptions = getSelectedOptions(true);
        },
        beforeSave: (args: BeforeSaveEventArgs) => {
            args.jsonConfig = getSelectedOptions();
        }
    });
    spreadsheet.appendTo('#spreadsheet');

    const multiSelect: MultiSelect = new MultiSelect({
        dataSource: ['Ignore Styles', 'Ignore Charts', 'Ignore Images', 'Ignore Formats',
            'Ignore Formulas', 'Ignore Validations', 'Ignore Merged Cells', 'Ignore Conditional Formats'],
        placeholder: "Select parse options",
        mode: 'CheckBox',
        showDropDownIcon: true,
        popupWidth: '240px'
    });
    multiSelect.appendTo('#open');

    const multiSelectSave: MultiSelect = new MultiSelect({
        dataSource: ['Only Values', 'Ignore Styles', 'Ignore Charts', 'Ignore Images',
            'Ignore Formats', 'Ignore Notes', 'Ignore Wraps', 'Ignore Formulas',
            'Ignore Validations', 'Ignore Freeze Panes', 'Ignore Conditional Formats'],
        placeholder: "Select serialization options",
        mode: 'CheckBox',
        showDropDownIcon: true,
        popupWidth: '240px'
    });
    multiSelectSave.appendTo('#save');

    const uploadObj: Uploader = new Uploader({
        cssClass: 'e-ss-uploader',
        allowedExtensions: '.xls, .xlsx, .csv, .xlsm, .xlsb',
        showFileList: true,
        buttons: { browse: 'Choose file' },
        multiple: false,
        selected: (args: any) => {
            files = args.filesData[0].rawFile;
        }
    });
    uploadObj.appendTo('#parse_upload');

    const openButton: Button = new Button({ isPrimary: true, content: 'Open' }, '#open_button');
    openButton.element.onclick = (): void => {
        if (files) {
            spreadsheet.open({ file: files });
        }
    }

    const saveButton: Button = new Button({ isPrimary: true, content: 'Save' }, '#save_button');
    saveButton.element.onclick = (): void => {
        spreadsheet.save({ fileName: 'Sample', saveType: 'Xlsx' });
    }

    function getSelectedOptions(isOpen?: boolean): { [key: string]: boolean } {
        const optionMap: { [key: string]: string } = {
            "Only Values": "onlyValues", "Ignore Styles": "ignoreStyle",
            "Ignore Charts": "ignoreChart", "Ignore Images": "ignoreImage",
            "Ignore Formats": "ignoreFormat", "Ignore Notes": "ignoreNote",
            "Ignore Wraps": "ignoreWrap", "Ignore Formulas": "ignoreFormula",
            "Ignore Validations": "ignoreValidation", "Ignore Merged Cells": "ignoreMergedCell",
            "Ignore Freeze Panes": "ignoreFreezePane", "Ignore Conditional Formats": "ignoreConditionalFormat"
        };
        const parseOptions: { [key: string]: boolean } = {};
        const selectedValues: string[] = isOpen ? multiSelect.value as string[] : multiSelectSave.value as string[];
        if (selectedValues && selectedValues.length > 0) {
            selectedValues.forEach((value: string) => {
                if (optionMap[value]) {
                    parseOptions[optionMap[value]] = true;
                }
            });
        }
        return parseOptions;
    }
}

```
