Docker Image Overview in EJ2 ASP.NET MVC Spreadsheet control

28 Jul 20263 minutes to read

The Syncfusion® Spreadsheet (also known as Excel Viewer) is a feature-rich control for organizing and analyzing data in a tabular format. It provides all the common Excel features, including data binding, selection, editing, formatting, resizing, sorting, filtering, importing, and exporting Excel documents.

This Docker image is a predefined Docker container for Syncfusion Spreadsheet server-side functionality. This server-side Web API project targets ASP.NET Core 8.0.

You can deploy it quickly to your infrastructure. If you want to add new functionality or customize any existing functionalities, create your own Dockerfile by referencing the existing Spreadsheet Docker project.

The Spreadsheet is supported on the JavaScript, Angular, React, Vue, ASP.NET Core, and ASP.NET MVC platforms.

Prerequisites

Have Docker installed in your environment:

How to deploy the Spreadsheet Docker Image

Step 1: Pull the spreadsheet-server image from Docker Hub.

docker pull syncfusion/spreadsheet-server

Step 2: Create the docker-compose.yml file with the following code in your file system.

version: '3.4' 

services:
  spreadsheet-server:
    image: syncfusion/spreadsheet-server:latest
    environment:
      # Provide your license key for activation
      SYNCFUSION_LICENSE_KEY: YOUR_LICENSE_KEY
    ports:
      - "6002:8080"

Note: The Spreadsheet is a commercial product. It requires a valid license key to use in a production environment. Please replace YOUR_LICENSE_KEY with the valid license key in the docker-compose.yml file.

Step 3: In a terminal tab, navigate to the directory where you’ve placed the docker-compose.yml file and execute the following:

docker-compose up

The Spreadsheet server is now available at http://localhost:6002.

Use the following endpoints for Spreadsheet file operations:

  • Open service: http://localhost:6002/api/spreadsheet/open
  • Save service: http://localhost:6002/api/spreadsheet/save

Step 4: Append the URLs of the Docker instance running services to the openUrl property as http://localhost:6002/api/spreadsheet/open and the saveUrl property as http://localhost:6002/api/spreadsheet/save in the client-side Spreadsheet control. For more information on how to get started with the Spreadsheet control, refer to this getting started page.

Add the following Spreadsheet configuration to the Razor view in which the Spreadsheet component is rendered. Configure the OpenUrl and SaveUrl properties to use the open and save endpoints exposed by the Docker container.

@Html.EJS().Spreadsheet("spreadsheet").OpenUrl("http://localhost:6002/api/spreadsheet/open").AllowOpen(true).SaveUrl("http://localhost:6002/api/spreadsheet/save").AllowSave(true).Render()

Run the ASP.NET MVC application and verify that the Spreadsheet can open and save Excel files using the configured Docker service endpoints.

How to configure different cultures using a Docker Compose file

By default, the Spreadsheet Docker container is generated in the en_US culture. You can configure different cultures using the LC_ALL, LANGUAGE, and LANG environment variables in the docker-compose.yml file. These environment variables are replaced in the Dockerfile to set the specified culture for the Spreadsheet server.

version: '3.4' 

services:
  spreadsheet-server:
    image: syncfusion/spreadsheet-server:latest
    environment:
      # Provide your license key for activation
      SYNCFUSION_LICENSE_KEY: YOUR_LICENSE_KEY
      # Specify the culture to configure for the Spreadsheet server
      LC_ALL: de_DE.UTF-8
      LANGUAGE: de_DE.UTF-8
      LANG: de_DE.UTF-8
    ports:
      - "6002:8080"

Please refer to these getting started pages to create a Spreadsheet in Angular, React, Vue, ASP.NET Core, and ASP.NET MVC.