Using the Shape element in SpreadJS with React, you can quickly embed and render various shapes including geometric figures like square, circle, rectangle, triangle, pentagon, hexagon, octagon etc. in the worksheets 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 shapes module in your project using the following command:
npm install @grapecity/spread-sheets-shapes |
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 shapes in a React Application.
JavaScript |
Copy Code
|
---|---|
import React from 'react'; // Import Shapes module var SpreadJSKey = "xxx"; class App extends React.Component { { // Handling workbook initialized event { // Fetching sheet // Setting Sheetname // Add built-in shape "donut" // Adding text to built-in shape "donut" // Adding style to built-in shape "donut" sheetShape.resumePaint(); } { export default App; |