Spread.Sheets supports React - a JavaScript library that allows developers to build user interfaces for web applications and mobile applications by handling the view layer of the MVC framework.
With React, you can modify data without reloading the page while creating reusable components and large applications.
Spread.Sheets can be used with React in the following two ways:
This method involves the following steps:
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 |
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:
JavaScript |
Copy Code
|
---|---|
import React, {Component} from 'react'; class APP extends Component { constructor(props) { {
render() { ( formatter="$#.00"></Column> export default APP |
This method involves the following steps:
You can download the react HTML template using the link https://reactjs.org/docs/try-react.html
Add references to the gc.spread.sheets.all.*.*.*.min.js, gc.spread.sheets.*.*.*.css and gc.spread.sheets.react.*.*.*.js files in the HTML template (i.e. your index.html file).
Now, you can use Spread.Sheets in your react application. As an example, you can use the sample code given below:
JavaScript |
Copy Code
|
---|---|
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Hello World</title> <script src="https://unpkg.com/react@16/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> <script src="./lib/gc.spread.sheets.all.*.*.*.min.js"></script> <link rel="stylesheet" type="text/css" href="./lib/gc.spread.sheets.excel2013white.*.*.*.min.css"> <script src="./lib/gc.spread.sheets.react.*.*.*.js"></script> </head> <body> <div id="root"></div> <script type="text/babel"> const {SpreadSheets, Worksheet, Column} = window.SpreadSheetsComponents; class App extends React.Component{ render(){ return( <div style={{width: '800px',height: '600px'}}> <SpreadSheets> <Worksheet name='first'> <Column dataField="Name"/> </Worksheet> </SpreadSheets> </div> ) } } ReactDOM.render( <App/>, document.getElementById('root') ); </script> |
The SpreadSheets, Worksheet, and Column are the basic elements with tag hierarchy. Other elements work by setting them. The main tag hierarchy is:
<SpreadSheets> <Worksheet> <Column></Column> ... </Worksheet> ... </SpreadSheets> |
The following topics list the element directives.