Using the Excel IO element in SpreadJS with React, you can quickly render and display the excel sheets on the webpages while also executing the import and export operations without any hassle.
Open the Command Prompt window and type the following commands:
npm install -g create-react-app create-react-app quick-start cd quick-start npm start |
After you finish, the react project will be created at the specified location in the directory. For more information on how to create a React project, refer to https://reactjs.org/docs/add-react-to-a-new-app.html
Next, you need to install @grapecity/spread-sheets-react in your project using the following command:
npm install @grapecity/spread-sheets-react |
Next, you need to import the SpreadJS CSS in your index.js file using the following code:
import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css'; |
Next, you need to install the Excel I/O and file-saver modules in your project using the following commands:
npm install @grapecity/spread-excelio npm install file-saver --save |
Now, you can modify the App.js file as per your requirements. Changes will be reflected when the browser window is refreshed. As an example, you can use the sample code given below:
This example shows how to use Excel IO elements in a React Application.
JavaScript |
Copy Code
|
---|---|
import React from 'react'; // Import ExcelIO module // Import file-saver module var SpreadJSKey = "xxx";
// You need to license the ExcelIO module separately using the same license key class App extends React.Component {
// Import Excel // Get an instance of IO class // Export Excel exportFile = () => { // Get an instance of IO class } |