# spreadsheet-editor-chart

> Spreadsheet sample visualizing data using chart feature by comparing the GDP of different countries with various years.

**Framework:** angular  **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/angular/spreadsheet-editor-chart.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-angular-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.component.html

```html
<div class="control-section">
    <ejs-spreadsheet #spreadsheet [openUrl]="openUrl" [saveUrl]="saveUrl" (created)="created()">
        <e-sheets>
            <e-sheet name="GDP">
                <e-rows>
                    <e-row [height]=30>
                        <e-cells>
                            <e-cell value="Gross Domestic Product (in trillions)" [style]="{ backgroundColor: '#e56590', color: '#fff', fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' }"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell [index]="6" [chart]="chart"></e-cell>
                        </e-cells>
                    </e-row>
                </e-rows>
                <e-ranges>
                    <e-range [dataSource]="data" startCell="A3"></e-range>
                </e-ranges>
                <e-columns>
                    <e-column [width]=80></e-column>
                    <e-column [width]=75></e-column>
                    <e-column [width]=75></e-column>
                    <e-column [width]=75></e-column>
                    <e-column [width]=75></e-column>
                </e-columns>
            </e-sheet>
        </e-sheets>
    </ejs-spreadsheet>
</div>
```

### src/components/spreadsheet-editor-chart/spreadsheet-editor.component.ts

```typescript
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { SpreadsheetComponent, ChartModel, SpreadsheetModule } from '@syncfusion/ej2-angular-spreadsheet';
import { GDPData } from '../datasource/spreadsheet-editor-data';
/**
 * Chart sample with import and export support.
 */
@Component({
    selector: 'control-content',
    templateUrl: 'spreadsheet-editor.component.html',
    encapsulation: ViewEncapsulation.None,
    standalone: true,
    imports: [SpreadsheetModule]
})

export class ChartController {
    @ViewChild('spreadsheet')
    spreadsheetObj!: SpreadsheetComponent;
    public chart: ChartModel[] = [{ type: "Column", range: "A3:E10" }];
    data: Object[] = GDPData();
    public openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
    public saveUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save';
    created() {
         // Formatting cells dynamically using cellFormat method
         this.spreadsheetObj.cellFormat({ backgroundColor: '#e56590', color: '#fff', fontWeight: 'bold', textAlign: 'center' }, 'A3:E3');
         // Applying currency format to the specified range.
         this.spreadsheetObj.numberFormat('$#,##0.00', 'B4:E10');
         // Merging the cells from A1 to E1
         this.spreadsheetObj.merge('A1:E1');
    }
}
```
