• Getting Started
  • Components
    • Barcodes
    • Buttons
    • Chartsupdated
    • Conversational UIupdated
    • Data Query
    • Date Inputs
    • Date Math
    • Dialogs
    • Drawing
    • Dropdownsupdated
    • Editor
    • Excel Export
    • File Saver
    • Filter
    • Gantt
    • Gauges
    • Gridupdated
    • Icons
    • Indicators
    • Inputsupdated
    • Labels
    • Layout
    • ListBox
    • ListView
    • Map
    • Menus
    • Navigation
    • Notification
    • Pager
    • PDF Export
    • PDFViewer
    • PivotGrid
    • Popup
    • ProgressBars
    • Ripple
    • Schedulerupdated
    • ScrollView
    • Sortable
    • Spreadsheetupdated
    • ToolBar
    • Tooltips
    • TreeList
    • TreeViewupdated
    • Typography
    • Uploads
    • Utilities
  • Styling & Themes
  • Common Features
  • Project Setup
  • Knowledge Base
  • Sample Applications
  • FAQ
  • Troubleshooting
  • Updates
  • Changelogs
New to Kendo UI for Angular? Start a free 30-day trial

Saving Files on the Server

The Excel Export component enables you to send the generated Excel file to a remote service.

To save a file on the server:

  1. Use the toDataURL method to get the base64-encoded contents.
  2. Post the contents to the server.

import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { products } from './products';

@Component({
    selector: 'my-app',
    template: `
        <button type="button" (click)="save(excelexport)">Save</button>
        <kendo-excelexport [data]="data" [fileName]="fileName" #excelexport>
            <kendo-excelexport-column field="ProductID">
            </kendo-excelexport-column>
            <kendo-excelexport-column field="ProductName">
            </kendo-excelexport-column>
        </kendo-excelexport>
    `
})
export class AppComponent {

    public data: any[] = products;

    public fileName: string = "Products.xlsx";

    constructor(private http: HttpClient) {
    }

    public save(component: any): void {
        component.toDataURL().then((dataURL: string) => {
            const base64 = dataURL.split(";base64,")[1];

            this.http.post(SAVE_URL, {
                base64: base64,
                fileName: this.fileName
            }).subscribe();
        });
    }
}

In this article

Not finding the help you need?