[] 
(Showing Draft Content)

React

You can perform the following steps to add the SpreadJS Designer Component in a React application:

  1. Create a React project by typing the following commands in Command Prompt.

    npm install -g create-react-app create-react-app designercomponent cd designercomponent npm start
  2. Install the following SpreadJS React modules to use SpreadJS Designer Component.

    npm install @mescius/spread-sheets npm install @mescius/spread-sheets-io npm install @mescius/spread-sheets-barcode npm install @mescius/spread-sheets-charts npm install @mescius/spread-sheets-languagepackages npm install @mescius/spread-sheets-pdf npm install @mescius/spread-sheets-print npm install @mescius/spread-sheets-shapes npm install @mescius/spread-sheets-tablesheet npm install @mescius/spread-sheets-pivot-addon npm install @mescius/spread-sheets-designer npm install @mescius/spread-sheets-designer-resources-en npm install @mescius/spread-sheets-react npm install @mescius/spread-sheets-designer-react
  3. Import the required modules using the following code snippet in App.js.

    import '@mescius/spread-sheets-designer-resources-en'; import {Designer} from '@mescius/spread-sheets-designer-react'; import '@mescius/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css' import '@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css'
  4. Render the Designer Component using the following code snippet in App.js.

    function App() { return ( <Designer styleInfo = {{width: "1500px", height: '90vh'}}></Designer> ); } export default App;
  5. Run the application.

    npm start

Access SpreadJS instance

You can also access the SpreadJS instance by using designerInitialized event. Follow steps 1, 2, and 3 as listed above and continue:

  1. To render the Designer Component and access the SpreadJS instance, you can use the following code snippet.

    function App() { return ( <Designer designerInitialized={designer => { getDesigner(designer) }} styleInfo={{ width: "100%", height: '98vh' }}></Designer > ); } // Function to get designer function getDesigner(designer) { //this is hosted spread instance var workbook = designer.getWorkbook(); var sheet = workbook.getActiveSheet(); sheet.setValue(1, 1, 'Test'); }

Apply License

The licensed version allows you to use all features of the SpreadJS Designer Component. You need to set the license key for SpreadJS and the Designer Component which can be done by using the following code snippet.

import React from 'react'; import '@mescius/spread-sheets-designer-resources-en'; import * as GC from '@mescius/spread-sheets'; import '@mescius/spread-sheets-designer'; import {Designer} from '@mescius/spread-sheets-designer-react'; import "@mescius/spread-sheets-io"; var sjsLicense = "sjs-distribution-key"; GC.Spread.Sheets.LicenseKey = sjsLicense; GC.Spread.Sheets.Designer.LicenseKey = " designer-component-distribution-key ";