|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: React Spreadsheet getting started with Create React App | Syncfusion |
| 4 | +description: Integrate and use the Syncfusion React Spreadsheet component using create react app. |
| 5 | +control: Spreadsheet |
| 6 | +platform: document-processing |
| 7 | +documentation: ug |
| 8 | +--- |
| 9 | + |
| 10 | +# Getting Started with Syncfusion Spreadsheet using Create React App |
| 11 | + |
| 12 | +This article provides a step-by-step guide for setting up a React application using Create React App and integrating Syncfusion Spreadsheet. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +Ensure the following requirements are met before starting: |
| 17 | +[System requirements for Syncfusion React Spreadsheet](https://ej2.syncfusion.com/react/documentation/system-requirement) |
| 18 | + |
| 19 | +## Create the React application |
| 20 | + |
| 21 | +The recommended approach is to use the [`Create React App`](https://github.com/facebook/create-react-app) tool for initializing your project. This tool sets up a development environment and optimizes the build for production. |
| 22 | + |
| 23 | +To create a new application using JavaScript: |
| 24 | + |
| 25 | +``` |
| 26 | +npx create-react-app my-app |
| 27 | +cd my-app |
| 28 | +``` |
| 29 | + |
| 30 | +or |
| 31 | + |
| 32 | +``` |
| 33 | +yarn create react-app my-app |
| 34 | +cd my-app |
| 35 | +``` |
| 36 | + |
| 37 | +To create a React application in `TypeScript` environment, run the following command: |
| 38 | + |
| 39 | +``` |
| 40 | +npx create-react-app my-app --template typescript |
| 41 | +cd my-app |
| 42 | +``` |
| 43 | + |
| 44 | +Besides using the [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) package runner tool, also create an application from the `npm init`. To begin with the `npm init`, upgrade the `npm` version to `npm 6`+. |
| 45 | + |
| 46 | +``` |
| 47 | +npm init react-app my-app |
| 48 | +cd my-app |
| 49 | +``` |
| 50 | + |
| 51 | +After running the above commands, the project will be created and all required dependencies will be installed automatically. |
| 52 | + |
| 53 | +## Install Syncfusion React Spreadsheet Packages |
| 54 | + |
| 55 | +To install the React Spreadsheet package, use the following command: |
| 56 | + |
| 57 | +``` |
| 58 | +npm install @syncfusion/ej2-react-spreadsheet --save |
| 59 | +``` |
| 60 | +or |
| 61 | + |
| 62 | +``` |
| 63 | +yarn add @syncfusion/ej2-react-grids |
| 64 | +``` |
| 65 | + |
| 66 | +## Import CSS |
| 67 | + |
| 68 | +Syncfusion React Spreadshet come with built-in [themes](https://ej2.syncfusion.com/react/documentation/appearance/theme). Import the CSS styles for the Srpeadsheet component and its dependent components in the `src/App.css` file. The example below demonstrates importing the `Tailwind 3` theme. |
| 69 | + |
| 70 | +```css |
| 71 | +@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css'; |
| 72 | +@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css'; |
| 73 | +@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css'; |
| 74 | +@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css'; |
| 75 | +@import '../node_modules/@syncfusion/ej2-lists/styles/tailwind3.css'; |
| 76 | +@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css'; |
| 77 | +@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css'; |
| 78 | +@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css'; |
| 79 | +@import '../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css'; |
| 80 | +@import '../node_modules/@syncfusion/ej2-react-spreadsheet/styles/tailwind3.css'; |
| 81 | +``` |
| 82 | + |
| 83 | +For more details on built-in themes and usage, refer to the [Themes topic](https://ej2.syncfusion.com/react/documentation/appearance/theme). |
| 84 | + |
| 85 | +## Adding Spreadsheet component |
| 86 | + |
| 87 | +Now, you can import the spreadsheet component into your `src/App.jsx` file. |
| 88 | + |
| 89 | +{% tabs %} |
| 90 | +{% highlight js tabtitle="app.jsx" %} |
| 91 | +import * as React from 'react'; |
| 92 | +import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet'; |
| 93 | +import './App.css'; |
| 94 | +export default function App() { |
| 95 | + return (<SpreadsheetComponent/>); |
| 96 | +} |
| 97 | +{% endhighlight %} |
| 98 | +{% highlight ts tabtitle="app.tsx" %} |
| 99 | +import * as React from 'react'; |
| 100 | +import { SpreadsheetComponent } from '@syncfusion/ej2-react-spreadsheet'; |
| 101 | +import './App.css'; |
| 102 | +export default function App() { |
| 103 | + return (<SpreadsheetComponent/>); |
| 104 | +} |
| 105 | +{% endhighlight %} |
| 106 | +{% endtabs %} |
| 107 | + |
| 108 | +## Run the application |
| 109 | +Run the app using the following commands: |
| 110 | + |
| 111 | +``` |
| 112 | +npm start |
| 113 | +``` |
| 114 | + |
| 115 | +or |
| 116 | + |
| 117 | +``` |
| 118 | +yarn start |
| 119 | +``` |
| 120 | + |
| 121 | +## See Also |
| 122 | +* [Getting Started with Syncfusion React Spreadsheet](https://help.syncfusion.com/document-processing/excel/spreadsheet/react/getting-started) |
0 commit comments