Get data from spreadsheet react

Simple, customizable yet performant spreadsheet for React

Simple

Straightforward API focusing on common use cases while keeping flexibility

Performant

Draw and update tables with many columns and rows without virtualization

Just Components™

The Spreadsheet is just a component, compose it easily with other components and data

09 Oct 2022 / 2 minutes to read

This section explains the steps to create a simple Spreadsheet component in a React application.

To get start quickly with React Spreadsheet, you can check on this video:

Dependencies

The following list of dependencies are required to use the Spreadsheet component in your application:

|-- @syncfusion/ej2-react-spreadsheet
      |-- @syncfusion/ej2-react-base
      |-- @syncfusion/ej2-spreadsheet
      |-- @syncfusion/ej2-base
      |-- @syncfusion/ej2-dropdowns
      |-- @syncfusion/ej2-navigations
      |-- @syncfusion/ej2-grids

Setup for Local Development

You can use create-react-app to setup the applications and run the following command to install create-react-app.

npm install -g create-react-app

Run the following command to setup the basic React samples.

create-react-app quickstart --scripts-version=react-scripts-ts

cd quickstart

npm install

Adding Syncfusion packages

All the available Essential JS 2 packages are published in npmjs.com public registry. To install Spreadsheet component use the following command.

npm install @syncfusion/ej2-react-spreadsheet --save

Adding CSS reference

Add components style as given below in src/App.css.

@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
@import '../node_modules/@syncfusion/ej2-grids/styles/material.css';
@import '../node_modules/@syncfusion/ej2-react-spreadsheet/styles/material.css';

To refer App.css in the application then import it in the src/App.tsx file.

Adding Spreadsheet component

Now, you can import the spreadsheet component into your src/App.tsx file.

import * as React from 'react';
import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet';
import './App.css';
export default class App extends React.Component {
     render() {
        return  (<SpreadsheetComponent/>);
    }
}

Run the application

The create-react-app will pre-configure the project to compile and run the application in browser. Use the following command to run the application.

The following example shows a basic spreadsheet component.

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet';
export default class App extends React.Component {
    render() {
        return (<SpreadsheetComponent />);
    }
}
ReactDOM.render(<App />, document.getElementById('root'));

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Spreadsheet</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/20.3.47/material.css" rel="stylesheet" type="text/css"/>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
    <style>
        #loader {
            color: #008cff;
            height: 40px;
            left: 45%;
            position: absolute;
            top: 45%;
            width: 30%;
        }
        body {
            overflow: hidden;
        }
    </style>
</head>

<body>
    <div id='root'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet';
export default class App extends React.Component<{}, {}> {
     render() {
        return  (<SpreadsheetComponent/>);
    }
}
ReactDOM.render(<App />, document.getElementById('root'));

You can refer to our React Spreadsheet feature tour page for its groundbreaking feature representations. You can also explore our React Spreadsheet example that shows you how to present and manipulate data.

See Also

  • Data Binding
  • Open and Save

Contents

  • Dependencies
  • Setup for Local Development
  • Adding Syncfusion packages
  • Adding CSS reference
  • Adding Spreadsheet component
  • Run the application
  • See Also

Contents

  • Dependencies
  • Setup for Local Development
  • Adding Syncfusion packages
  • Adding CSS reference
  • Adding Spreadsheet component
  • Run the application
  • See Also

How do you get data from Google sheets in React JS?

Click the share button on the top right of your screen, and edit the permission to public. Copy the link and go to https://sheet.best/ and create your free account. Create a new connection and paste your copied URL from the Google Sheets in the connection URL box. Click on connect.

How does ReactJS read data from Excel?

To read Excel files in React, we can use the xlsx package. We define the onChange function that takes the file from the file input with: const [file] = e. target.

How do I use Google Spreadsheet API in React?

Go to Google Cloud Console to get API key for Google Sheets API..
Create a Google Sheet and add some data. See example sheet..
Share it with "Anyone with this link can view"..
Get sheet id from url of the sheet..

How do you upload Excel file in React JS?

In this article, we gonna learn how to import and export excel and csv in react..
Let's install create-react-app package. npm i -g create-react-app. ... .
Create a new react project. create-react-app react-excel-csv. ... .
Install xlsx npm package. ... .
Create folder components inside the src folder. ... .
Open the App. ... .
Finally start the project..