Import Excel files using server-side processing in Vue Spreadsheet

25 Nov 202624 minutes to read

The Vue Spreadsheet Editor component uses a server-assisted workflow to open Excel files efficiently and accurately. When a user uploads an Excel file, the file is sent to a server endpoint for processing. This keeps the browser fast and responsive, as all heavy parsing and conversion are handled on the server.

On the server, the Syncfusion.EJ2.Spreadsheet library is used to process the uploaded Excel file. This library is built on top of Syncfusion XlsIO, which itself is implemented using .NET Frameworks. The server extracts all data, styles, formulas, formatting, and sheet structure, then converts everything into a Spreadsheet-compatible JSON format. This JSON is sent back to the client, where the Vue Spreadsheet component renders the workbook in the browser, preserving the original Excel layout and content.

For open processing, the server receives the uploaded Excel file and processes it with the Syncfusion XlsIO library. This library reads the Office Open XML format and extracts all relevant information. Based on this extracted information, it generates a workbook-compatible JSON structure that the Spreadsheet component can understand and load. During this process, all Spreadsheet-supported features are retained and properly mapped to the client-side representation.

In the code samples and demos, you may see Syncfusion-hosted service URLs used for the openUrl and saveUrl properties. These URLs point to Syncfusion’s own WebAPI services (built with ASP.NET Core) that handle opening and saving Excel files. These hosted URLs are provided only for demonstration and evaluation purposes:

Hosted Syncfusion Service URLs

openUrl='https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open'
saveUrl='https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save'

For your own development and production, you must set up your own web service for open/save operations. This ensures your data remains private, secure, and fully under your control. Using your own service also allows you to customize processing, apply business logic, and comply with your organization’s security requirements.

Server Configuration

Below is an example of a server-side Open endpoint using ASP.NET Core WebAPI, which is the same approach used for building the hosted Syncfusion URLs. This endpoint receives the uploaded Excel file, processes it with the Syncfusion Spreadsheet library, and returns the workbook JSON to the client:

// Open action
[HttpPost]
[Route("Open")]
public IActionResult Open([FromForm] IFormCollection openRequest)
{
    OpenRequest open = new OpenRequest();
    if (openRequest.Files.Count > 0) {
        open.File = openRequest.Files[0];
        return Content(Workbook.Open(open));
    }
    return BadRequest("No file uploaded.");
}

Note: For details on how to set up your own web service for open/save operations, refer to the web service section of this documentation.

Install Required Dependencies

For spreadsheet open and save operations, install the following NuGet packages based on your server platform:

Platform Assembly NuGet Package
ASP.NET Core Syncfusion.EJ2.Spreadsheet.AspNet.Core
Syncfusion.EJ2.AspNet.Core
Syncfusion.XlsIORenderer.Net.Core
Syncfusion.EJ2.Spreadsheet.AspNet.Core
Syncfusion.EJ2.AspNet.Core
Syncfusion.XlsIORenderer.Net.Core
ASP.NET MVC5 Syncfusion.XlsIO.AspNet.Mvc5
Syncfusion.ExcelToPdfConverter.AspNet.Mvc5
Syncfusion.Pdf.AspNet.Mvc5
Syncfusion.ExcelChartToImageConverter.AspNet.Mvc5
Syncfusion.EJ2.MVC5
Syncfusion.XlsIO.AspNet.Mvc5
Syncfusion.ExcelToPdfConverter.AspNet.Mvc5
Syncfusion.Pdf.AspNet.Mvc5
Syncfusion.ExcelChartToImageConverter.AspNet.Mvc5
Syncfusion.EJ2.MVC5

For more details, see the dependencies section on nuget.org.

To enable opening Excel files, set the allowOpen property to true and specify the service url using the openUrl property. The control will send the uploaded file to this endpoint, where it is processed and returned as JSON for the Spreadsheet to render.

For a quick walkthrough on how the open functionality works, refer to the following video:

UI options to open Excel files

In the user interface you can open an Excel document by clicking File > Open menu item in ribbon.

The following sample shows the Open option configured by using the openUrl property. You can also use the beforeOpen event to customize or cancel the import action, which is triggered before opening an Excel file.

<template>
  <ejs-spreadsheet :openUrl="openUrl" :allowOpen="true" :beforeOpen="beforeOpen"></ejs-spreadsheet>
</template>

<script setup>
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";

const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
const beforeOpen = function (args) {
  // your code snippets here
}
</script>

<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>
<template>
  <ejs-spreadsheet :openUrl="openUrl" :allowOpen="true" :beforeOpen="beforeOpen"></ejs-spreadsheet>
</template>

<script>
import { SpreadsheetComponent } from "@syncfusion/ej2-vue-spreadsheet";

export default {
  name: "App",
  components: {
    "ejs-spreadsheet": SpreadsheetComponent
  },
  data: () => {
    return {
      openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open'
    }
  },
  methods: {
    beforeOpen: function (args) {
      // your code snippets here
    }
  }
}
</script>

<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>

Please find the below table for the beforeOpen event arguments.

BeforeOpenEventArgs - Properties

Property Type Description
cancel boolean Specifies whether the open action should be canceled.
file FileList or string or File Specifies the file to be opened.
parseOptions WorkbookParseOptions Specifies the parsing options that control how the Excel file is interpreted during loading.
password string Specifies the password required to open the Excel file, if it is protected.
requestData object Specifies any additional data sent along with the open request.
requestType string Specifies the type of open request that triggered the beforeOpen event. Possible values:

• initial - The default request made when loading a workbook.
• chunk - A follow-up request to load a portion of the workbook when chunking is enabled and the server provides a chunk plan.
• thresholdLimitConfirmed - A request made after the user confirms a threshold warning (such as maximumDataLimit or maximumFileSizeLimit) and chooses to proceed.
  • Use Ctrl + O keyboard shortcut to open Excel documents.
  • The default value of the allowOpen property is true. For demonstration purpose, we have showcased the allowOpen property in previous code snippet.

Open Excel files programmatically

To open Excel files programmatically in the Spreadsheet, you can use the open method of the Spreadsheet component. Before invoking this method, ensure that the openUrl property is properly configured, as it is required for processing the file on the server.

Please find the table below for the open method arguments.

Parameter Type Description
options OpenOptions Options for opening the excel file.

The following code example demonstrates how to open an Excel file programmatically in the Spreadsheet.

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :saveUrl="saveUrl" :created="created" />
</template>

<script setup>
import { ref } from 'vue';
import { SpreadsheetComponent as EjsSpreadsheet } from '@syncfusion/ej2-vue-spreadsheet';

const spreadsheet = ref(null);
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
const saveUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save';

const created = () => {
  fetch('https://js.syncfusion.com/demos/ejservices/data/Spreadsheet/LargeData.xlsx')
    .then((response) => response.blob())
    // Convert the Blob to a File and open it in the Spreadsheet.
    .then((blob) => spreadsheet.value.open({ file: new File([blob], 'Sample.xlsx') }));
};
</script>

Supported Excel file formats for Open

The following Excel file formats are supported for opening in the Spreadsheet component:

  • Microsoft Excel Workbook (.xlsx)
  • Microsoft Excel 97-2003 Workbook (.xls)
  • Comma-Separated Values (.csv)
  • Excel Macro-Enabled Workbook (.xlsm)
  • Excel Binary Workbook (.xlsb)

Import options

Open Excel files from local system

If you explore your machine to choose and upload an Excel document using the file upload component, you will receive the uploaded document as a raw file in the success event of the file upload component. In this success event, you should pass the received raw file as an argument to the Spreadsheet’s open method to see the appropriate output.

The following code example shows how to import an Excel document using file upload component in spreadsheet.

<template>
  <div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :openUrl="openUrl"></ejs-spreadsheet>
    <ejs-uploader :asyncSettings="path" :success="onSuccess" :allowedExtensions="allowExtentions"></ejs-uploader>
  </div>
</template>

<script setup>
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";
import { UploaderComponent as EjsUploader } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

const allowExtentions = ".xlsx, .xls, .csv";
const path = {
  saveUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
  removeUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Remove",
}
const openUrl = "https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open";

const onSuccess = (args) => {
  let spreadsheet = getComponent(
    document.getElementById("spreadsheet"),
    "spreadsheet"
  );
  if (args.operation === "upload")
    spreadsheet.value.open({ file: args.file.rawFile });
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-vue-spreadsheet/styles/tailwind3.css";
</style>
<template>
  <div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :openUrl="openUrl"></ejs-spreadsheet>
    <ejs-uploader :asyncSettings="path" :success="onSuccess" :allowedExtensions="allowExtentions"></ejs-uploader>
  </div>
</template>

<script>
import { SpreadsheetComponent } from "@syncfusion/ej2-vue-spreadsheet";
import { UploaderComponent } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

export default {
  name: "App",
  components: {
    "ejs-spreadsheet": SpreadsheetComponent,
    "ejs-uploader": UploaderComponent
  },
  data: () => {
    return {
      allowExtentions: ".xlsx, .xls, .csv",
      path: {
        saveUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
        removeUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Remove"
      },
      openUrl: "https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open"
    }
  },
  methods: {
    onSuccess: (args) => {
      let spreadsheet = getComponent(
        document.getElementById("spreadsheet"),
        "spreadsheet"
      );
      if (args.operation === "upload")
        spreadsheet.open({ file: args.file.rawFile });
    },
  },
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-vue-spreadsheet/styles/tailwind3.css";
</style>

Open Excel files from URL

You can achieve to access the remote Excel file by using the created event. In this event you can fetch the Excel file and convert it to a blob. Convert this blob to a file and open this file by using Spreadsheet component open method.

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :allowOpen="true" :created="created"></ejs-spreadsheet>
</template>

<script setup>
import { ref } from "vue";
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";

const spreadsheet = ref(null);
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';

const created = function () {
  fetch("https://cdn.syncfusion.com/scripts/spreadsheet/Sample.xlsx") // fetch the remote url
    .then((response) => {
      response.blob().then((fileBlob) => { // convert the excel file to blob
        let file = new File([fileBlob], "Sample.xlsx"); //convert the blob into file
        spreadsheet.value.open({ file: file }); // open the file into Spreadsheet
      })
    })
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>
<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :allowOpen="true" :created="created"></ejs-spreadsheet>
</template>

<script>
import { SpreadsheetComponent } from "@syncfusion/ej2-vue-spreadsheet";

export default {
  name: "App",
  components: {
    "ejs-spreadsheet": SpreadsheetComponent
  },
  data: () => {
    return {
      openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
    }
  },
  methods: {
    created: function () {
      fetch("https://cdn.syncfusion.com/scripts/spreadsheet/Sample.xlsx") // fetch the remote url
        .then((response) => {
          response.blob().then((fileBlob) => { // convert the excel file to blob
            let file = new File([fileBlob], "Sample.xlsx"); //convert the blob into file
            this.$refs.spreadsheet.open({ file: file }); // open the file into Spreadsheet
          })
        })
    }
  }
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>

Open Excel files from Blob Data

By default, the Spreadsheet component provides an option to browse files from the local file system and open them within the component. If you want to open an Excel file from blob data, you need to fetch the blob data from the server or another source and convert this blob data into a File object. Then, you can use the open method in the Spreadsheet component to load that File object.

Please find the code to fetch the blob data and load it into the Spreadsheet component below.

<template>
  <div>
    <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :saveUrl="saveUrl" :created="created">
    </ejs-spreadsheet>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";

let base64String = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQAAAAIAP1o41i4AvtcvQIAAHISAAANAAAAeGwvc3R5bGVzLnhtbOxYW2vbMBT+K0LvreM0ydoQp2yFQGGUsm4wGHuQZdkR1cXIcrH363ckO3bSJOvW9iEDv0RHx/q+c9ElOlpcV1KgJ2YKrlWEw/MRRkxRnXCVRbi06dklRoUlKiFCKxbhmhX4erkobC3Yw5oxi4BAFXNJI7y2Np8HQUHXTJLiXOdMwcdUG0ksdE0WSGIey/yMapkTy2MuuK2D8Wg0w0jS+W2mtCGxADNVOCEUt9y+s0cvOTW60Kk9B7pApymnLChyw0hSOMekcMxXwVXQMf2Ni3sMM/CaK7xcpFrZAlFdKhvhaauAVPxCT0RA7kKMguVCEckaxQ0RPDbca+mamAKS5T+MvCpo4APJfk58U0BuuBBdxse4USwXsHYsM2oFHdTKX+scVo2CJepGZTdaaIO4SljFkgjPJp493tNPG6tbhM64b14wlRlSh+Ppe1nzDUQca5PAZtzEHOKNarkQLLUOb3i29oLVubejrdXSSQknmVZEeCsbWCsAN2VCPLh9+z3tk+oiqFKkSrmS9jbxE+GyvxHBrVZseNpOcBwVHkeRPBf1R8EzJZmzvlF98oP6/l0pY2ZWflf2WpewvndvtGXU+mPrP3NoPDj0QoZGpzZlg0NDhoY1NOyy4Rxyp+Hk4l3/XV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A2bm6aztGM7egpy4YtfiULG1JIYmAb9wal/Y+6rAgWlL8usbilDk1Bw5BYxlfkkXSn2ZOTYPpfrrDHGWaW765X+7l57EnQoqC0nmhf6Sswa3d+yJDtmYf+P0Xfm5KTPVnPzCQAA//8DAFBLAQItABQAAAAIAP1o41i4AvtcvQIAAHISAAANAAAAAAAAAAAAIAAAAAAAAAB4bC9zdHlsZXMueG1sUEsBAi0AFAAAAAgA/WjjWIfBZr0CAwAAswgAABQAAAAAAAAAAAAgAAAA6AIAAHhsL3NoYXJlZFN0cmluZ3MueG1sUEsBAi0AFAAAAAgA/WjjWCh9DXz3BgAABiQAABgAAAAAAAAAAAAgAAAAHAYAAHhsL3dvcmtzaGVldHMvc2hlZXQxLnhtbFBLAQItABQAAAAIAP1o41hCIqOORgEAAEICAAAPAAAAAAAAAAAAIAAAAEkNAAB4bC93b3JrYm9vay54bWxQSwECLQAUAAAACAD9aONYjtrdGNsAAAA3AgAAGgAAAAAAAAAAACAAAAC8DgAAeGwvX3JlbHMvd29ya2Jvb2sueG1sLnJlbHNQSwECLQAUAAAACAD9aONYG//Mt7EAAADsAAAAEAAAAAAAAAAAACAAAADPDwAAZG9jUHJvcHMvYXBwLnhtbFBLAQItABQAAAAIAP1o41imPZqHJwEAADYCAAARAAAAAAAAAAAAIAAAAK4QAABkb2NQcm9wcy9jb3JlLnhtbFBLAQItABQAAAAIAP1o41hPWDYmmAAAAOUAAAATAAAAAAAAAAAAIAAAAAQSAABkb2NQcm9wcy9jdXN0b20ueG1sUEsBAi0AFAAAAAgA/WjjWMpXjwxKAQAAowQAABMAAAAAAAAAAAAgAAAAzRIAAFtDb250ZW50X1R5cGVzXS54bWxQSwECLQAUAAAACAD9aONYuBL2w/kAAADhAgAACwAAAAAAAAAAACAAAABIFAAAX3JlbHMvLnJlbHNQSwUGAAAAAAoACgCAAgAAahUAAAAA";
const spreadsheet = ref(null);
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
const saveUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save';

const created = function () {
  // To obtain blob data from base64 string.
  fetch(base64String)
    .then((response) => response.blob())
    .then((fileBlob) => {
      // To convert obtained blob data as a file.
      let file = new File([fileBlob], 'Sample.xlsx');
      spreadsheet.value.open({ file: file });
    });
}

</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

.custom-btn {
  margin-bottom: 10px;
}
</style>
<template>
  <div>
    <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :saveUrl="saveUrl" :created="created">
    </ejs-spreadsheet>
  </div>
</template>

<script>
import { SpreadsheetComponent } from "@syncfusion/ej2-vue-spreadsheet";

let base64String = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQAAAAIAP1o41i4AvtcvQIAAHISAAANAAAAeGwvc3R5bGVzLnhtbOxYW2vbMBT+K0LvreM0ydoQp2yFQGGUsm4wGHuQZdkR1cXIcrH363ckO3bSJOvW9iEDv0RHx/q+c9ElOlpcV1KgJ2YKrlWEw/MRRkxRnXCVRbi06dklRoUlKiFCKxbhmhX4erkobC3Yw5oxi4BAFXNJI7y2Np8HQUHXTJLiXOdMwcdUG0ksdE0WSGIey/yMapkTy2MuuK2D8Wg0w0jS+W2mtCGxADNVOCEUt9y+s0cvOTW60Kk9B7pApymnLChyw0hSOMekcMxXwVXQMf2Ni3sMM/CaK7xcpFrZAlFdKhvhaauAVPxCT0RA7kKMguVCEckaxQ0RPDbca+mamAKS5T+MvCpo4APJfk58U0BuuBBdxse4USwXsHYsM2oFHdTKX+scVo2CJepGZTdaaIO4SljFkgjPJp493tNPG6tbhM64b14wlRlSh+Ppe1nzDUQca5PAZtzEHOKNarkQLLUOb3i29oLVubejrdXSSQknmVZEeCsbWCsAN2VCPLh9+z3tk+oiqFKkSrmS9jbxE+GyvxHBrVZseNpOcBwVHkeRPBf1R8EzJZmzvlF98oP6/l0pY2ZWflf2Wpewvndvt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components: {
    "ejs-spreadsheet": SpreadsheetComponent
  },
  data: () => {
    return {
      openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
      saveUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save'
    }
  },
  methods: {
    created: function () {
      let spreadsheet = this.$refs.spreadsheet;
      // To obtain blob data from base64 string.
      fetch(base64String)
        .then((response) => response.blob())
        .then((fileBlob) => {
          // To convert obtained blob data as a file.
          let file = new File([fileBlob], 'Sample.xlsx');
          spreadsheet.open({ file: file });
        });
    }
  }
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

.custom-btn {
  margin-bottom: 10px;
}
</style>

Load Workbook as JSON

The Spreadsheet component allows you to load an entire workbook using a JSON object. This JSON is typically generated by the Spreadsheet server by converting an Excel file into a Spreadsheet-compatible workbook JSON, but it can also be created manually. When loaded, the component reads the JSON and restores all workbook details, including sheets, cells, styles, formulas, formatting, and other associated metadata.

You can optionally pass deserialization options to the openFromJson method to ignore specific features when loading the JSON. For example, you can exclude styles, formulas, number formats, images, or conditional formatting. These options are optional-if you do not specify them, the method restores the full workbook details by default.

Reference: Guide to Creating the JSON Structure: https://help.syncfusion.com/document-processing/excel/spreadsheet/vue/how-to/create-a-object-structure.

The following example demonstrates how to load a workbook JSON into the Spreadsheet component.

<template>
  <div>
      <div id="Openfromjson">
      <label id="Heading">Open From Json Options:</label> <br>
      <input type="checkbox" id="valueOnly" @change="toggleCheckboxes"><label for="valueOnly">Only Values</label>
      <input type="checkbox" id="style"><label for="style">Ignore Style</label>
      <input type="checkbox" id="formula"><label for="formula">Ignore Formula</label>
      <input type="checkbox" id="format"><label for="format">Ignore Format</label>
      <input type="checkbox" id="cf"><label for="cf">Ignore CF</label>
      <input type="checkbox" id="dv"><label for="dv">Ignore Validation</label>
      <input type="checkbox" id="freeze"><label for="freeze">Ignore Freezepane</label>
      <input type="checkbox" id="wrap"><label for="wrap">Ignore Wrap</label>
      <input type="checkbox" id="chart"><label for="chart">Ignore Chart</label>
      <input type="checkbox" id="image"><label for="image">Ignore Image</label>
      <input type="checkbox" id="note"><label for="note">Ignore Note</label>
      <ejs-uploader
        :asyncSettings="path"
        :success="onSuccess"
        :allowedExtensions="allowExtentions"
        :buttons="buttons"
        :showFileList="false"
      ></ejs-uploader>
    </div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :beforeOpen="beforeOpen">
    </ejs-spreadsheet>
</div>
</template>

<script setup>
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";
import { UploaderComponent as EjsUploader } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

const allowExtentions = ".xlsx, .xls, .csv";
const path = {
  saveUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
  removeUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Remove",
};
const buttons = { browse: 'Choose file' };
const onSuccess = (args) => {
  var spreadsheet = getComponent(
    document.getElementById("spreadsheet"),
    "spreadsheet"
  );
  if (args.operation === "upload")
    spreadsheet.open({ file: args.file.rawFile });
}
const beforeOpen = (args) => {
  args.cancel = true;
  var valueOnlyCheckbox = document.getElementById("valueOnly").checked;
  var options = valueOnlyCheckbox ? { onlyValues: true } : createOptions;
  var spreadsheet = getComponent(
    document.getElementById("spreadsheet"),
    "spreadsheet"
  );
  fetch(
    'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
    args.requestData
  ).then((response) => {
    response.json().then((data) => {
      spreadsheet.openFromJson({ file: data }, options)
    });
  });
};
const createOptions = () => {
  var options = {};
  options.ignoreStyle = document.getElementById('style').checked;
  options.ignoreFormula = document.getElementById('formula').checked;
  options.ignoreFormat = document.getElementById('format').checked;
  options.ignoreConditionalFormat = document.getElementById('cf').checked;
  options.ignoreValidation = document.getElementById('dv').checked;
  options.ignoreFreezePane = document.getElementById('freeze').checked;
  options.ignoreWrap = document.getElementById('wrap').checked;
  options.ignoreChart = document.getElementById('chart').checked;
  options.ignoreImage = document.getElementById('image').checked;
  options.ignoreNote = document.getElementById('note').checked;
  return options;
};
const toggleCheckboxes = () => {
  var valueOnlyCheckbox = document.getElementById('valueOnly');
  var checkboxes = document.querySelectorAll('#Openfromjson input[type="checkbox"]:not(#valueOnly)');
  checkboxes.forEach(checkbox => {
    (checkbox).disabled = valueOnlyCheckbox.checked;
    if (valueOnlyCheckbox.checked) {
      (checkbox).checked = false;
    }
  });
};

</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

#Openfromjson {
  margin-top: 10px;
  margin-bottom: 20px;
}
    
#Openfromjson input[type="checkbox"] {
  margin: 7px;
}
    
#Openfromjson label {
  font-size: 14px;
}
    
#Heading {
  font-weight: bold;
  margin-left: 6px;
}
</style>
<template>
  <div>
      <div id="Openfromjson">
      <label id="Heading">Open From Json Options:</label> <br>
      <input type="checkbox" id="valueOnly" @change="toggleCheckboxes"><label for="valueOnly">Only Values</label>
      <input type="checkbox" id="style"><label for="style">Ignore Style</label>
      <input type="checkbox" id="formula"><label for="formula">Ignore Formula</label>
      <input type="checkbox" id="format"><label for="format">Ignore Format</label>
      <input type="checkbox" id="cf"><label for="cf">Ignore CF</label>
      <input type="checkbox" id="dv"><label for="dv">Ignore Validation</label>
      <input type="checkbox" id="freeze"><label for="freeze">Ignore Freezepane</label>
      <input type="checkbox" id="wrap"><label for="wrap">Ignore Wrap</label>
      <input type="checkbox" id="chart"><label for="chart">Ignore Chart</label>
      <input type="checkbox" id="image"><label for="image">Ignore Image</label>
      <input type="checkbox" id="note"><label for="note">Ignore Note</label>
      <ejs-uploader
        :asyncSettings="path"
        :success="onSuccess"
        :allowedExtensions="allowExtentions"
        :buttons="buttons"
        :showFileList="false"
      ></ejs-uploader>
    </div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :beforeOpen="beforeOpen">
    </ejs-spreadsheet>
</div>
</template>

<script>
import { SpreadsheetComponent } from '@syncfusion/ej2-vue-spreadsheet';
import { UploaderComponent } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

export default {
  components: {
  'ejs-uploader': UploaderComponent,
  'ejs-spreadsheet': SpreadsheetComponent,
 },  
 data: () => {
  return {
    allowExtentions: ".xlsx, .xls, .csv",
    path: {
      saveUrl:
        "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
      removeUrl:
        "https://services.syncfusion.com/vue/production/api/FileUploader/Remove",
    },
    buttons: { browse: 'Choose file' }
  }
},
methods: {
  onSuccess: function(args) {
    var spreadsheet = getComponent(
      document.getElementById("spreadsheet"),
      "spreadsheet"
    );
    if (args.operation === "upload")
      spreadsheet.open({ file: args.file.rawFile });
  },
  beforeOpen: function(args) {
    args.cancel = true;
    var valueOnlyCheckbox = document.getElementById("valueOnly").checked;
    var options = valueOnlyCheckbox ? { onlyValues: true } : this.createOptions();
    var spreadsheet = getComponent(
      document.getElementById("spreadsheet"),
      "spreadsheet"
    );
    fetch(
        'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
        args.requestData
    ).then((response) => {
        response.json().then((data) => {
            spreadsheet.openFromJson({ file: data }, options)
        });
    });
  },
  createOptions: function() {
    var options = {};
    options.ignoreStyle = document.getElementById('style').checked;
    options.ignoreFormula = document.getElementById('formula').checked;
    options.ignoreFormat = document.getElementById('format').checked;
    options.ignoreConditionalFormat = document.getElementById('cf').checked;
    options.ignoreValidation = document.getElementById('dv').checked;
    options.ignoreFreezePane = document.getElementById('freeze').checked;
    options.ignoreWrap = document.getElementById('wrap').checked;
    options.ignoreChart = document.getElementById('chart').checked;
    options.ignoreImage = document.getElementById('image').checked;
    options.ignoreNote = document.getElementById('note').checked;
    return options;
  },
  toggleCheckboxes: () => {
    var valueOnlyCheckbox = document.getElementById('valueOnly');
    var checkboxes = document.querySelectorAll('#Openfromjson input[type="checkbox"]:not(#valueOnly)');
    checkboxes.forEach(checkbox => {
        (checkbox).disabled = valueOnlyCheckbox.checked;
        if (valueOnlyCheckbox.checked) {
            (checkbox).checked = false;
        }
    });
  }
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

#Openfromjson {
  margin-top: 10px;
  margin-bottom: 20px;
}
    
#Openfromjson input[type="checkbox"] {
  margin: 7px;
}
    
#Openfromjson label {
  font-size: 14px;
}
    
#Heading {
  font-weight: bold;
  margin-left: 6px;
}
</style>

Load server-side Excel files into Spreadsheet

By default, the Spreadsheet component provides an option to browse files from the local file system and open them within the component. If you want to load an Excel file located on a server, you need to configure the server endpoint to fetch the Excel file from the server location, process it using Syncfusion.EJ2.Spreadsheet.AspNet.Core, and send it back to the client side as JSON data. On the client side, you should use the openFromJson method to load that JSON data into the Spreadsheet component.

Server Endpoint:

    public IActionResult Open([FromBody] FileOptions options)
    {
        OpenRequest open = new OpenRequest();
        string filePath = _env.ContentRootPath.ToString() + "\\Files\\" + options.FileName + ".xlsx";
        // Getting the file stream from the file path.
        FileStream fileStream = new FileStream(filePath, FileMode.Open);
        // Wrap the file stream as an IFormFile.
        IFormFile formFile = new FormFile(fileStream, 0, fileStream.Length, "", options.FileName + ".xlsx");
        open.File = formFile;
        // Processing the Excel file and return the workbook JSON.
        var result = Workbook.Open(open);
        fileStream.Close();
        return Content(result);
    }

    public class FileOptions
    {
        public string FileName { get; set; } = string.Empty;
    }

Client Side:

Place this code inside a <script setup> handler after the Spreadsheet is created.

    // Fetch call to server to load the Excel file.
    fetch('https://localhost:/Home/Open', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ FileName: 'Sample' }),
    })
    .then((response) => response.json())
    .then((data) => {
            // Load the JSON data into spreadsheet.
            spreadsheet.value.openFromJson({ file: data });
    })

You can find the server endpoint code to fetch and process the Excel file in this attachment. After launching the server endpoint, you need to update the URL on the client side sample as shown below.

// To open an Excel file from the server.
fetch('https://localhost:/Home/Open')

Open Excel files with AWS Lambda

Before proceeding with the opening process, you should deploy the spreadsheet open/save web API service in AWS Lambda. To host the open/save web service in the AWS Lambda environment, please refer to the following KB documentation.

How to deploy a spreadsheet open and save web API service to AWS Lambda

After deployment, you will get the AWS service URL for the open and save actions. Before opening the Excel file with this hosted open URL, you need to prevent the default file opening process to avoid getting a corrupted file on the open service end. The spreadsheet component appends the file to the formData and sends it to the open service, which causes the file to get corrupted. To prevent this, set the args.cancel value to true in the beforeOpen event. After that, you will get the chosen file in the beforeOpen event argument. Then, convert this file into a base64 string and send it to the open service URL using a fetch request.

On the open service end, convert the base64 string back to a file and pass it as an argument to the workbook Open method. The open service will process the file and return the spreadsheet data in JSON format. You will then receive this JSON data in the fetch success callback. Finally, use the openFromJson method to load this JSON data into the spreadsheet component.

The following code example shows how to open an Excel file using a hosted web service in AWS Lambda, as mentioned above.

<script setup>
import { ref } from 'vue';
import { SpreadsheetComponent as EjsSpreadsheet } from '@syncfusion/ej2-vue-spreadsheet';

const spreadsheet = ref(null);
const openUrl = 'https://your-api.execute-api.your-region.amazonaws.com/Prod/api/spreadsheet/open';
const beforeOpen = (args) => {
    // Prevent the default open action.
    args.cancel = true;
    if (!(args.file instanceof File)) return;
    const file = args.file;
    const reader = new FileReader();
    reader.onload = async () => {
      // Send the Base64 file data to AWS for open processing.
      const response = await fetch(openUrl, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          // Remove the data URL prefix to send only the Base64 file content.
          file: String(reader.result).split(',')[1],
          extension: file.name.split('.').pop(),
          password: args.password || ''
        })
      });
      if (!response.ok) throw new Error('Open request failed.');
      const data = await response.json();
      // Load the returned workbook JSON into the Spreadsheet.
      spreadsheet.value.openFromJson({ file: data });
    };
    reader.readAsDataURL(file);
};
</script>

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :beforeOpen="beforeOpen" />

</template>
<script>
import { SpreadsheetComponent } from '@syncfusion/ej2-vue-spreadsheet';

export default {
  components: { 'ejs-spreadsheet': SpreadsheetComponent },
  data() {
    return {
      openUrl: 'https://your-api.execute-api.your-region.amazonaws.com/Prod/api/spreadsheet/open'
    };
  },
  methods: {
    beforeOpen(args) {
    // Prevent the default open action.
    args.cancel = true;
    if (!(args.file instanceof File)) return;
    const file = args.file;
    const reader = new FileReader();
    reader.onload = async () => {
      // Send the Base64 file data to AWS for open processing.
      const response = await fetch(this.openUrl, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          // Remove the data URL prefix to send only the Base64 file content.
          file: String(reader.result).split(',')[1],
          extension: file.name.split('.').pop(),
          password: args.password || ''
        })
      });
      if (!response.ok) throw new Error('Open request failed.');
      const data = await response.json();
      // Load the returned workbook JSON into the Spreadsheet.
      this.$refs.spreadsheet.openFromJson({ file: data });
    };
    reader.readAsDataURL(file);
    }
  }
};
</script>

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :beforeOpen="beforeOpen" />

</template>
public IActionResult Open([FromBody] OpenOptions openOptions)
{
    // Convert the base64 string to bytes array.
    byte[] bytes = Convert.FromBase64String(openOptions.File);
    // Loading the bytes array to stream.
    MemoryStream stream = new MemoryStream(bytes);
    OpenRequest open = new OpenRequest();
    // Converting the stream into FormFile.
    open.File = new FormFile(stream, 0, bytes.Length, "Sample", "Sample." + openOptions.Extension);
    if (!string.IsNullOrEmpty(openOptions.Password))
        open.Password = openOptions.Password;
    var result = Workbook.Open(open);
    return Content(result);
}

public class OpenOptions
{
    public string File { get; set; } = string.Empty;
    public string Password { get; set; } = string.Empty;
    public string Extension { get; set; } = string.Empty;
}

Open Base64-encoded Excel data

In the Spreadsheet, there is no direct option to open data as a Base64 string. To achieve this, the import() function fetches the Base64 string, converts it to a Blob, creates a File object from the Blob, and then opens it using the open method in the spreadsheet.

The following code example shows how to open the spreadsheet data as base64 string.

<template>
  <div>
    <ejs-button class="e-btn custom-btn" v-on:click.native="importBtn">Import Base64</ejs-button>
    <ejs-button class="e-btn custom-btn" v-on:click.native="exportBtn">Export as Base64</ejs-button>
    <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :beforeSave="beforeSave" :saveComplete="saveComplete">
      <e-sheets>
        <e-sheet name="Car Sales Report">
          <e-ranges>
            <e-range :dataSource="dataSource"></e-range>
          </e-ranges>
          <e-columns>
            <e-column :width=180></e-column>
            <e-column :width=130></e-column>
            <e-column :width=130></e-column>
            <e-column :width=180></e-column>
            <e-column :width=120></e-column>
            <e-column :width=130></e-column>
          </e-columns>
        </e-sheet>
      </e-sheets>
    </ejs-spreadsheet>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { SpreadsheetComponent as EjsSpreadsheet, SheetsDirective as ESheets, SheetDirective as ESheet, RangesDirective as ERanges, RangeDirective as ERange, ColumnsDirective as EColumns, ColumnDirective as EColumn } from "@syncfusion/ej2-vue-spreadsheet";
import { data } from './data.js';
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";

let base64String;
const spreadsheet = ref(null);
const dataSource = data;
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
const beforeSave = function (args) {
  args.needBlobData = true; // To trigger the saveComplete event.
  args.isFullPost = false; // Get the spreadsheet data as blob data in the saveComplete event.
}
const saveComplete = function (args) {
  // Convert blob data to base64 string.
  let reader = new FileReader();
  reader.readAsDataURL(args.blobData);
  reader.onloadend = function () {
    base64String = reader.result;
  };
}
const importBtn = function () {
  fetch(base64String)
    .then((response) => response.blob())
    .then((fileBlob) => {
      let file = new File([fileBlob], 'Sample.xlsx');
      spreadsheet.value.open({ file: file });
    });
}

const exportBtn = function () {
  spreadsheet.value.save({
    url: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save',
    fileName: 'Worksheet',
    saveType: 'Xlsx',
  }); // Specifies the save URL, file name, file type need to be saved.
  // Logs base64 string into the console.
  console.log('Base64 String - ', base64String);
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

.custom-btn {
  margin-bottom: 10px;
}
</style>
<template>
  <div>
    <ejs-button class="e-btn custom-btn" v-on:click.native="importBtn">Import Base64</ejs-button>
    <ejs-button class="e-btn custom-btn" v-on:click.native="exportBtn">Export as Base64</ejs-button>
    <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :beforeSave="beforeSave" :saveComplete="saveComplete">
      <e-sheets>
        <e-sheet name="Car Sales Report">
          <e-ranges>
            <e-range :dataSource="dataSource"></e-range>
          </e-ranges>
          <e-columns>
            <e-column :width=180></e-column>
            <e-column :width=130></e-column>
            <e-column :width=130></e-column>
            <e-column :width=180></e-column>
            <e-column :width=120></e-column>
            <e-column :width=130></e-column>
          </e-columns>
        </e-sheet>
      </e-sheets>
    </ejs-spreadsheet>
  </div>
</template>

<script>
import { SpreadsheetComponent, SheetsDirective, SheetDirective, RangesDirective, RangeDirective, ColumnsDirective, ColumnDirective } from "@syncfusion/ej2-vue-spreadsheet";
import { data } from './data.js';
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";

let base64String;
export default {
  name: "App",
  components: {
    "ejs-button": ButtonComponent,
    "ejs-spreadsheet": SpreadsheetComponent,
    "e-sheets": SheetsDirective,
    "e-sheet": SheetDirective,
    "e-ranges": RangesDirective,
    "e-range": RangeDirective,
    "e-columns": ColumnsDirective,
    "e-column": ColumnDirective
  },
  data: () => {
    return {
      dataSource: data,
      openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open'
    }
  },
  methods: {
    beforeSave: function (args) {
      args.needBlobData = true; // To trigger the saveComplete event.
      args.isFullPost = false; // Get the spreadsheet data as blob data in the saveComplete event.
    },
    saveComplete: function (args) {
      // Convert blob data to base64 string.
      let reader = new FileReader();
      reader.readAsDataURL(args.blobData);
      reader.onloadend = function () {
        base64String = reader.result;
      };
    },
    importBtn: function () {
      let spreadsheet = this.$refs.spreadsheet;
      fetch(base64String)
        .then((response) => response.blob())
        .then((fileBlob) => {
          let file = new File([fileBlob], 'Sample.xlsx');
          spreadsheet.open({ file: file });
        });
    },
    exportBtn: function () {
      let spreadsheet = this.$refs.spreadsheet;
      spreadsheet.save({
        url: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/save',
        fileName: 'Worksheet',
        saveType: 'Xlsx',
      }); // Specifies the save URL, file name, file type need to be saved.
      // Logs base64 string into the console.
      console.log('Base64 String - ', base64String);
    }
  }
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

.custom-btn {
  margin-bottom: 10px;
}
</style>

Open Excel files in read-only mode

You can open Excel file into a read-only mode by using the openComplete event. In this event, you must protect all the sheets and lock its used range cells by using protectSheet and lockCells methods.

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :allowOpen="true"
    :openComplete="openComplete"></ejs-spreadsheet>
</template>

<script setup>
import { ref } from "vue";
import { SpreadsheetComponent as EjsSpreadsheet, getRangeAddress } from "@syncfusion/ej2-vue-spreadsheet";

const spreadsheet = ref(null);
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';

const openComplete = function () {
  let sheets = spreadsheet.value.sheets;
  for (let index = 0; index < sheets.length; index++) {
    let name = spreadsheet.value.sheets[index].name;
    let protectSetting = {
      selectCells: true,
      formatCells: false,
    };
    //To protect the sheet using sheet name
    spreadsheet.value.protectSheet(name, protectSetting);
    let address = getRangeAddress([
      0,
      0,
      sheets[index].usedRange.rowIndex,
      sheets[index].usedRange.colIndex,
    ]);
    //To lock the used range cells
    spreadsheet.value.lockCells(name + '!' + address, true);
  }
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>
<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :allowOpen="true"
    :openComplete="openComplete"></ejs-spreadsheet>
</template>

<script>
import { SpreadsheetComponent, getRangeAddress } from "@syncfusion/ej2-vue-spreadsheet";

export default {
  name: "App",
  components: {
    "ejs-spreadsheet": SpreadsheetComponent
  },
  data: () => {
    return {
      openUrl: 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
    }
  },
  methods: {
    openComplete: function () {
      let spreadsheet = this.$refs.spreadsheet.ej2Instances;
      let sheets = spreadsheet.sheets;
      for (let index = 0; index < sheets.length; index++) {
        let name = spreadsheet.sheets[index].name;
        let protectSetting = {
          selectCells: true,
          formatCells: false,
        };
        //To protect the sheet using sheet name
        spreadsheet.protectSheet(name, protectSetting);
        let address = getRangeAddress([
          0,
          0,
          sheets[index].usedRange.rowIndex,
          sheets[index].usedRange.colIndex,
        ]);
        //To lock the used range cells
        spreadsheet.lockCells(name + '!' + address, true);
      }
    }
  }
}
</script>

<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';
</style>

Advanced Open Options

Configure JSON Deserialization

Previously, when opening a workbook JSON object into the Spreadsheet using the openFromJson method, the entire workbook, including all features specified in the JSON object, was processed and loaded into the Spreadsheet.

Now, you have the option to selectively ignore some features during the opening of the JSON object by configuring deserialization options and passing them as arguments to the openFromJson method. This argument is optional, and if not configured, the entire workbook JSON object will be loaded without ignoring any features.

spreadsheet.value.openFromJson({ file: file }, { ignoreStyle: true });
Option Description
onlyValues If true, only cell values are loaded.
ignoreStyle If true, styles are excluded when loading the JSON data.
ignoreFormula If true, formulas are excluded when loading the JSON data.
ignoreFormat If true, number formats are excluded when loading the JSON data.
ignoreConditionalFormat If true, conditional formatting is excluded when loading the JSON data.
ignoreValidation If true, data validation rules are excluded when loading the JSON data.
ignoreFreezePane If true, freeze panes are excluded when loading the JSON data.
ignoreWrap If true, text wrapping settings are excluded when loading the JSON data.
ignoreChart If true, charts are excluded when loading the JSON data.
ignoreImage If true, images are excluded when loading the JSON data.
ignoreNote If true, notes are excluded when loading the JSON data.

The following code snippet demonstrates how to configure the deserialization options and pass them as arguments to the openFromJson method:

<template>
  <div>
      <div id="Openfromjson">
      <label id="Heading">Open From Json Options:</label> <br>
      <input type="checkbox" id="valueOnly" @change="toggleCheckboxes"><label for="valueOnly">Only Values</label>
      <input type="checkbox" id="style"><label for="style">Ignore Style</label>
      <input type="checkbox" id="formula"><label for="formula">Ignore Formula</label>
      <input type="checkbox" id="format"><label for="format">Ignore Format</label>
      <input type="checkbox" id="cf"><label for="cf">Ignore CF</label>
      <input type="checkbox" id="dv"><label for="dv">Ignore Validation</label>
      <input type="checkbox" id="freeze"><label for="freeze">Ignore Freezepane</label>
      <input type="checkbox" id="wrap"><label for="wrap">Ignore Wrap</label>
      <input type="checkbox" id="chart"><label for="chart">Ignore Chart</label>
      <input type="checkbox" id="image"><label for="image">Ignore Image</label>
      <input type="checkbox" id="note"><label for="note">Ignore Note</label>
      <ejs-uploader
        :asyncSettings="path"
        :success="onSuccess"
        :allowedExtensions="allowExtentions"
        :buttons="buttons"
        :showFileList="false"
      ></ejs-uploader>
    </div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :beforeOpen="beforeOpen">
    </ejs-spreadsheet>
</div>
</template>

<script setup>
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";
import { UploaderComponent as EjsUploader } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

const allowExtentions = ".xlsx, .xls, .csv";
const path = {
  saveUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
  removeUrl: "https://services.syncfusion.com/vue/production/api/FileUploader/Remove",
};
const buttons = { browse: 'Choose file' };
const onSuccess = (args) => {
  var spreadsheet = getComponent(
    document.getElementById("spreadsheet"),
    "spreadsheet"
  );
  if (args.operation === "upload")
    spreadsheet.open({ file: args.file.rawFile });
}
const beforeOpen = (args) => {
  args.cancel = true;
  var valueOnlyCheckbox = document.getElementById("valueOnly").checked;
  var options = valueOnlyCheckbox ? { onlyValues: true } : createOptions;
  var spreadsheet = getComponent(
    document.getElementById("spreadsheet"),
    "spreadsheet"
  );
  fetch(
    'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
    args.requestData
  ).then((response) => {
    response.json().then((data) => {
      spreadsheet.openFromJson({ file: data }, options)
    });
  });
};
const createOptions = () => {
  var options = {};
  options.ignoreStyle = document.getElementById('style').checked;
  options.ignoreFormula = document.getElementById('formula').checked;
  options.ignoreFormat = document.getElementById('format').checked;
  options.ignoreConditionalFormat = document.getElementById('cf').checked;
  options.ignoreValidation = document.getElementById('dv').checked;
  options.ignoreFreezePane = document.getElementById('freeze').checked;
  options.ignoreWrap = document.getElementById('wrap').checked;
  options.ignoreChart = document.getElementById('chart').checked;
  options.ignoreImage = document.getElementById('image').checked;
  options.ignoreNote = document.getElementById('note').checked;
  return options;
};
const toggleCheckboxes = () => {
  var valueOnlyCheckbox = document.getElementById('valueOnly');
  var checkboxes = document.querySelectorAll('#Openfromjson input[type="checkbox"]:not(#valueOnly)');
  checkboxes.forEach(checkbox => {
    (checkbox).disabled = valueOnlyCheckbox.checked;
    if (valueOnlyCheckbox.checked) {
      (checkbox).checked = false;
    }
  });
};

</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

#Openfromjson {
  margin-top: 10px;
  margin-bottom: 20px;
}
    
#Openfromjson input[type="checkbox"] {
  margin: 7px;
}
    
#Openfromjson label {
  font-size: 14px;
}
    
#Heading {
  font-weight: bold;
  margin-left: 6px;
}
</style>
<template>
  <div>
      <div id="Openfromjson">
      <label id="Heading">Open From Json Options:</label> <br>
      <input type="checkbox" id="valueOnly" @change="toggleCheckboxes"><label for="valueOnly">Only Values</label>
      <input type="checkbox" id="style"><label for="style">Ignore Style</label>
      <input type="checkbox" id="formula"><label for="formula">Ignore Formula</label>
      <input type="checkbox" id="format"><label for="format">Ignore Format</label>
      <input type="checkbox" id="cf"><label for="cf">Ignore CF</label>
      <input type="checkbox" id="dv"><label for="dv">Ignore Validation</label>
      <input type="checkbox" id="freeze"><label for="freeze">Ignore Freezepane</label>
      <input type="checkbox" id="wrap"><label for="wrap">Ignore Wrap</label>
      <input type="checkbox" id="chart"><label for="chart">Ignore Chart</label>
      <input type="checkbox" id="image"><label for="image">Ignore Image</label>
      <input type="checkbox" id="note"><label for="note">Ignore Note</label>
      <ejs-uploader
        :asyncSettings="path"
        :success="onSuccess"
        :allowedExtensions="allowExtentions"
        :buttons="buttons"
        :showFileList="false"
      ></ejs-uploader>
    </div>
    <ejs-spreadsheet id="spreadsheet" ref="spreadsheet" :beforeOpen="beforeOpen">
    </ejs-spreadsheet>
</div>
</template>

<script>
import { SpreadsheetComponent } from '@syncfusion/ej2-vue-spreadsheet';
import { UploaderComponent } from "@syncfusion/ej2-vue-inputs";
import { getComponent } from "@syncfusion/ej2-base";

export default {
  components: {
  'ejs-uploader': UploaderComponent,
  'ejs-spreadsheet': SpreadsheetComponent,
 },  
 data: () => {
  return {
    allowExtentions: ".xlsx, .xls, .csv",
    path: {
      saveUrl:
        "https://services.syncfusion.com/vue/production/api/FileUploader/Save",
      removeUrl:
        "https://services.syncfusion.com/vue/production/api/FileUploader/Remove",
    },
    buttons: { browse: 'Choose file' }
  }
},
methods: {
  onSuccess: function(args) {
    var spreadsheet = getComponent(
      document.getElementById("spreadsheet"),
      "spreadsheet"
    );
    if (args.operation === "upload")
      spreadsheet.open({ file: args.file.rawFile });
  },
  beforeOpen: function(args) {
    args.cancel = true;
    var valueOnlyCheckbox = document.getElementById("valueOnly").checked;
    var options = valueOnlyCheckbox ? { onlyValues: true } : this.createOptions();
    var spreadsheet = getComponent(
      document.getElementById("spreadsheet"),
      "spreadsheet"
    );
    fetch(
        'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open',
        args.requestData
    ).then((response) => {
        response.json().then((data) => {
            spreadsheet.openFromJson({ file: data }, options)
        });
    });
  },
  createOptions: function() {
    var options = {};
    options.ignoreStyle = document.getElementById('style').checked;
    options.ignoreFormula = document.getElementById('formula').checked;
    options.ignoreFormat = document.getElementById('format').checked;
    options.ignoreConditionalFormat = document.getElementById('cf').checked;
    options.ignoreValidation = document.getElementById('dv').checked;
    options.ignoreFreezePane = document.getElementById('freeze').checked;
    options.ignoreWrap = document.getElementById('wrap').checked;
    options.ignoreChart = document.getElementById('chart').checked;
    options.ignoreImage = document.getElementById('image').checked;
    options.ignoreNote = document.getElementById('note').checked;
    return options;
  },
  toggleCheckboxes: () => {
    var valueOnlyCheckbox = document.getElementById('valueOnly');
    var checkboxes = document.querySelectorAll('#Openfromjson input[type="checkbox"]:not(#valueOnly)');
    checkboxes.forEach(checkbox => {
        (checkbox).disabled = valueOnlyCheckbox.checked;
        if (valueOnlyCheckbox.checked) {
            (checkbox).checked = false;
        }
    });
  }
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-tailwind3-theme/styles/spreadsheet/index.css';

#Openfromjson {
  margin-top: 10px;
  margin-bottom: 20px;
}
    
#Openfromjson input[type="checkbox"] {
  margin: 7px;
}
    
#Openfromjson label {
  font-size: 14px;
}
    
#Heading {
  font-weight: bold;
  margin-left: 6px;
}
</style>

Optimize Open Performance with Parsing Options

Opening large Excel files into the Vue Spreadsheet can sometimes lead to slower performance and increased memory usage. This is often caused by the processing of additional elements such as styles and number formats—even when the actual data content is minimal. For example, an Excel file with only a small amount of data but a large number of styled or formatted empty cells can significantly impact load time and memory consumption.

To address this, we’ve introduced parsing options that allow users to selectively skip non-essential features during the open process. By enabling options like IgnoreStyle and IgnoreFormat, you can reduce the amount of data processed, resulting in:

  • Faster load times
  • Lower memory usage
  • Smaller JSON responses

These enhancements are especially beneficial for users working with large or complex Excel files, offering a more efficient and responsive experience.

Note: These options are ideal when styles and number formats are not critical to your use case and the focus is on loading the actual data efficiently.

The code example below demonstrates how to configure the IgnoreStyle and IgnoreFormat parsing options on the server-side.

Code Snippet:

Server-Side Configuration:

public IActionResult Open(IFormCollection openRequest)
{
    OpenRequest open = new OpenRequest();
    open.File = openRequest.Files[0];
    open.ParseOptions = new WorkbookParseOptions() {
        IgnoreStyle = true,
        IgnoreFormat = true
    };
    return Content(Workbook.Open(open));
}

Open Large Excel Files with Chunk Response Processing

When opening large Excel files with many features and data, the server response can become very large. This might cause memory issues or connection problems during data transmission. The Chunk Response Processing feature solves this by dividing the server response into smaller parts, called chunks, and sending them to the client in parallel. The client receives these chunks and combines them to load the Excel data smoothly into the spreadsheet.

You can enable this feature by setting the chunkSize property in the openSettings object. Set the chunkSize to a value greater than 0 (in bytes). The chunkSize defines how large each chunk will be. Make sure your server supports chunked responses to use this feature effectively.

This feature reduces memory usage on both the server and client, ensuring that resources are managed efficiently during data transmission. By sending smaller parts of data, it prevents connection issues that could occur with large payloads, making the transmission process more reliable. Additionally, it allows large Excel files to be loaded smoothly into the spreadsheet, providing a seamless user experience even with extensive data.

The following code example demonstrates the client-side and server-side configuration required for handling chunk-based responses when opening an Excel file.

Client Side:

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" :openSettings="openSettings" />
</template>

<script setup>
import { ref } from 'vue';
import { SpreadsheetComponent as EjsSpreadsheet } from '@syncfusion/ej2-vue-spreadsheet';

const spreadsheet = ref(null);
const openUrl = 'https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open';
// chunkSize specifies the server response chunk size in bytes.
// retryCount specifies how many times to retry a failed chunk request.
// retryAfterDelay specifies the delay in milliseconds between retries.
const openSettings = { chunkSize: 1000000, retryCount: 3, retryAfterDelay: 500 };
</script>

Server Endpoint:

public IActionResult Open(IFormCollection openRequest)
{
    OpenRequest open = new OpenRequest();
    if (openRequest.Files.Count > 0)
    {
        open.File = openRequest.Files[0];
    }
    Microsoft.Extensions.Primitives.StringValues chunkPayload;
    if (openRequest.TryGetValue("chunkPayload", out chunkPayload))
    {
        // The chunk payload JSON data includes information essential for processing chunked responses.
        open.ChunkPayload = chunkPayload;
    }
    var result = Workbook.Open(open, 150);
    return Content(result);
}

The attachment includes the server endpoint code for handling chunk-based open processing. After launching the server endpoint, update the openUrl property of the spreadsheet in the client-side sample with the server URL, as shown below.

<template>
  <ejs-spreadsheet ref="spreadsheet" :openUrl="openUrl" />
</template>

<script setup>
import { ref } from 'vue';
import { SpreadsheetComponent as EjsSpreadsheet } from '@syncfusion/ej2-vue-spreadsheet';

const spreadsheet = ref(null);
// Specify the service URL that processes the Excel file and returns workbook JSON.
const openUrl = 'https://localhost:/Home/Open';
</script>

Customization

Add custom headers to Open requests

You can add your own custom header to the open action in the Spreadsheet. For processing the data, it has to be sent from server to client side and adding customer header can provide privacy to the data with the help of Authorization Token. Through the beforeOpen event, the custom header can be added to the request during open action.

<template>
  <ejs-spreadsheet :openUrl="openUrl" :allowOpen="true" :beforeOpen="beforeOpen"></ejs-spreadsheet>
</template>

<script setup>
import { SpreadsheetComponent as EjsSpreadsheet } from "@syncfusion/ej2-vue-spreadsheet";

const openUrl = "https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open";

const beforeOpen = function (args) {
  args.requestData = {
    ...args.requestData,
    headers: { Authorization: "YOUR TEXT" }
  };
}
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-vue-spreadsheet/styles/tailwind3.css";
</style>
<template>
  <ejs-spreadsheet :openUrl="openUrl" :allowOpen="true" :beforeOpen="beforeOpen"></ejs-spreadsheet>
</template>

<script>
import { SpreadsheetComponent } from "@syncfusion/ej2-vue-spreadsheet";

export default {
  name: "App",
  components: {
    "ejs-spreadsheet": SpreadsheetComponent
  },
  data: () => {
    return {
      openUrl:
        "https://document.syncfusion.com/web-services/spreadsheet-editor/api/spreadsheet/open",
    };
  },
  methods: {
    beforeOpen: function (args) {
      args.requestData = {
        ...args.requestData,
        headers: { Authorization: "YOUR TEXT" },
      };
    },
  },
};
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
@import "../node_modules/@syncfusion/ej2-vue-spreadsheet/styles/tailwind3.css";
</style>

Handle External workbook reference confirmation

When you open an Excel file that contains external workbook references, you will see a confirmation dialog. This dialog allows you to either continue with the file opening or cancel the operation. This confirmation dialog will appear only if you set the AllowExternalWorkbook property value to false during the open request, as shown below. This prevents the spreadsheet from displaying inconsistent data.

public IActionResult Open(IFormCollection openRequest)
    {
        OpenRequest open = new OpenRequest();
        open.AllowExternalWorkbook = false;
        open.File = openRequest.Files[0];
        open.Guid = openRequest["Guid"];
        return Content(Workbook.Open(open));
    }

This feature is only applicable when importing an Excel file and not when loading JSON data or binding cell data.

External workbook confirmation dialog