简体   繁体   English

尝试将 SpreadJS 设计器组件集成到 React 项目中

[英]Trying to integrate SpreadJS Designer Component in a React Project

So I've been trying to integrate SpreadJS Designer Component ( npm module ) into my React project following this Quick Start guide for React .所以我一直在尝试按照这个 React 快速入门指南将 SpreadJS 设计器组件( npm 模块)集成到我的 React 项目中。 After trying for some time I got it to work like this, Spreadsheet is working (shapes, charts, colors and etc)在尝试了一段时间后,我让它像这样工作,电子表格正在工作(形状、图表、colors 等)

<Designer styleInfo={{ width: "100%", height: "calc(100vh - 25px)" }} />

But how can I input a JSON file into this through props?但是如何通过道具将 JSON 文件输入到这个文件中? What other props are there to access?还有哪些其他道具可以访问? I couldn't find any documentation related to this.我找不到与此相关的任何文档。 I'm looking for a prop to get and set the document JSON.我正在寻找一个道具来获取和设置文档 JSON。 that's pretty much it.差不多就是这样。

Update: And maybe get an onChanged event or something.更新:也许会得到一个 onChanged 事件或其他东西。 I really don't know what the props are as there is no documentation relating to this.我真的不知道道具是什么,因为没有与此相关的文档。

I am a member of GrapeCity's Technical Engagement team supporting SpreadJS and the Designer Component Add-on.我是 GrapeCity 技术参与团队的成员,支持SpreadJS和 Designer Component Add-on。

To import JSON data to your SpreadJS instance, instead of using props, you are able to use SpreadJS's fromJSON method .要将 JSON 数据导入您的 SpreadJS 实例,而不是使用道具,您可以使用 SpreadJS 的fromJSON 方法 You can implement this method when the worksheet is being initialized to have the JSON data imported to the SpreadJS instance as the page loads.您可以在初始化工作表时实现此方法,以便在页面加载时将 JSON 数据导入到 SpreadJS 实例。

Here is a link to our live React demo , please notice on the app.jsx file there is an initSpread function that imports JSON data using the spread.fromJSON . 这是我们现场 React 演示的链接,请注意app.jsx文件中有一个initSpread function 使用spread.fromJSON导入 JSON 数据。 The initSpread function is applied when the workbook is being initialized using the workbookInitialized event listener like so:当使用workbookInitialized事件侦听器初始化工作簿时,将应用 initSpread function,如下所示:

<div class="sample-spreadsheets">
   <SpreadSheets workbookInitialized={spread => this.initSpread(spread)}>
     <Worksheet>
     </Worksheet>
   </SpreadSheets>
 </div>

The JSON data will then be imported as the workbook is being initialized.然后在初始化工作簿时导入 JSON 数据。 Please import the JSON data using the fromJSON method.请使用 fromJSON 方法导入 JSON 数据。 Let me know if you have any questions about what I shared by reaching out here or by submitting a support ticket with our team here .如果您对我分享的内容有任何疑问,请告诉我,请在此处联系或向我们的团队提交支持票 Thank you, Mackenzie谢谢你,麦肯齐

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM