Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React implementation for JS-XLSX In-Browser HTML Table Edit Demo #1960

Open
parulcoer opened this issue May 21, 2020 · 4 comments
Open

React implementation for JS-XLSX In-Browser HTML Table Edit Demo #1960

parulcoer opened this issue May 21, 2020 · 4 comments

Comments

@parulcoer
Copy link

@parulcoer parulcoer commented May 21, 2020

I want to know if there is any implementation of the demo https://sheetjs.com/demo/modify.html in react. I am new to React and want to implement the similar functionality.

@SheetJSDev
Copy link
Contributor

@SheetJSDev SheetJSDev commented Jun 3, 2020

The modify demo is fairly simplistic.

When the file is read, the first worksheet is rendered to an HTML TABLE. On export, the table data is scraped and the resulting file is exported.

You can do this in react by using a ref on the container element. On read, you would set the innerHTML directly. On write, the ref gives you easy access to the live dom element.

@code-trekker
Copy link

@code-trekker code-trekker commented Aug 3, 2020

I tried the demo, and noticed that when I dropped my own Excel file and changed around the contents, the resulting downloaded file will contain the unchanged data instead.

@tarikhamilton
Copy link

@tarikhamilton tarikhamilton commented Oct 27, 2020

I'm down to do this, but I just wanted some feedback on what I think are the expectations. Would it be to recreate the existing demo, but fully functioning with modern React code, such as using hooks (v16.8+)? Is there an existing code style? I would use prettier, if none is specified.

Also, is the React demo on the deployed docs? I can't find a way to navigate to it.

@SheetJSDev
Copy link
Contributor

@SheetJSDev SheetJSDev commented Sep 23, 2021

@tarikhamilton the demos are not "deployed" anywhere. for react, you can spin up a local web server (with python -mSimpleHTTPServer or npx http-server).

Instead of working through HTML, it's probably better to demo an editable grid component that is built specifically for react. Instead of pulling from the rendered grid, it would be better to use the underlying state. The "read" part of the demo would update the state based on the data in the file while the "write" part would extract the state and generate a workbook.

One open question is whether to create an external demo or contribute code to the projects directly. For example, react-data-grid demo page has an export and it might make sense to contribute an importer there. For react-table, react-table-plugins has an export so it may make sense to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants