New to Kendo UI for Vue? Start a free 30-day trial

Saving Files on the Server

Using the Kendo UI for Vue Excel Export functionality, you can 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.
<template>
  <div>
      <button @click="exportExcel" class="k-button">Export Excel</button>
  </div>
</template>

<script>
import { toDataURL } from '@progress/kendo-vue-excel-export';
import products from './products.json';

export default {
    data: function () {
        return {
          columns: [
                  { field: 'ProductID'},
                  { field: 'ProductName', title: 'Product Name' },
              ]
        }
    },
    methods: {
        exportExcel () {
          toDataURL({
            data: products,
            fileName: "myFile",
            columns: this.columns
          }).then((dataURL) => {
            const base64 = dataURL.split(";base64,")[1];

            fetch(SAVE_URL, {
                method: 'POST',
                body: {
                    base64: base64,
                    fileName: this.fileName
                }
            });
        });
      }
    }
};

</script>

In this article

Not finding the help you need?