# spreadsheet-editor-chart

> Spreadsheet editor visualizing data using chart feature by comparing the GDP of different countries with various years.

**Framework:** javascript  **Component:** Spreadsheet  **Variant:** chart

## 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-chart.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-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-chart/spreadsheet-editor.html

```html
<div class="control-section">
    <div class="control-wrapper">
        <div id="spreadsheet"></div>
    </div>
</div>
<!-- custom code start -->
<style>
    .control-section .control-wrapper {
        height: calc(100vh - 230px);
        min-height: 550px
    }

    #sb-content .e-spreadsheet .e-tab .e-tab-text {
        display: inherit;
    }

    /* newTab support styles */
    .ej2-new .sb-header,
    .ej2-new .sb-bread-crumb,
    .ej2-new #action-description,
    .ej2-new #description-section,
    .ej2-new #description {
        display: none
    }

    .ej2-new .container-fluid,
    .ej2-new .container-fluid .control-section,
    #sidebar-section {
        padding: 0px;
    }

    .ej2-new .sample-browser>.content.e-view {
        top: 0px;
        padding: 0px;
        text-align: initial;
        height: 100%;
        overflow: hidden;
    }

    /* end of newTab support styles */
</style>
<!-- custom code end -->
```

### src/components/spreadsheet-editor-chart/spreadsheet-editor.ts

```typescript
import { Spreadsheet, getFormatFromType } from '@syncfusion/ej2-spreadsheet';
import { GDPData } from '../datasource/spreadsheet-editor-data';

/**
 * Chart
 */
export function initSpreadsheetEditorChart(): void {
    //Initialize Spreadsheet component.
    let spreadsheet: Spreadsheet = new Spreadsheet({
        sheets: [
            {
                name: 'GDP',
                ranges: [{ dataSource: GDPData, startCell: 'A3' }],
                rows: [
                    {
                        height: 30,
                        cells: [
                            {
                                value: 'Gross Domestic Product (in trillions)',
                                style: {
                                    backgroundColor: '#D21856', color: '#F5F5F5',
                                    fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle'
                                }
                            }
                        ]
                    },
                    {
                        cells: [
                            { index: 6, chart: [{ type: 'Column', range: 'A3:E10' }] }
                        ]
                    }
                ],
                columns: [
                    { width: 80 }, { width: 75 }, { width: 75 }, { width: 75 }, { width: 75 }
                ]
            }
        ],
        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: () => {
             // Formatting cells dynamically using cellFormat method
             spreadsheet.cellFormat({ backgroundColor: '#D21856', color: '#F5F5F5', fontWeight: 'bold', textAlign: 'center' }, 'A3:E3');
             // Applying currency format to the specified range.
             spreadsheet.numberFormat('$#,##0.00', 'B4:E10');
             // Merging the cells from A1 to E1
             spreadsheet.merge('A1:E1');
        }
    });
    //Render initialized Spreadsheet component
    spreadsheet.appendTo('#spreadsheet');
}

```
