o-spreadsheet icon indicating copy to clipboard operation
o-spreadsheet copied to clipboard

add o-spreadsheet in existing react project

Open Mar4ikler opened this issue 1 year ago • 2 comments

I can't implement simple example in existing react project, because Model and Spreadsheet exports does not exist, any hints?

Mar4ikler avatar Aug 02 '24 19:08 Mar4ikler

Hi !

Unfortunately we exclusively focus on the integration in Odoo which does not require hybrid integration with React, we might have overlooked crucial elements to ease that step. That being said, let's try to sort it out.

Could you elaborate on your usecase? Maybe with an example of which code you are starting from?

Generally speaking, If you want to use the library in an outside project there are 2 approaches.

1. build from scratch

build the library (npm run dist) and use the compiled file that suits your need (they are located in <rootDir>/dist.

2. load the npm package @odoo/o-spreadsheet

You can then find the same files in <rootDir>/node_modules/@odoo/o-spreadsheet/dist

The file iife will automatically add the global varialbe o_spreadsheet to window -> you can invoke window.o_spreadsheet, in which you will find all the useful classes like Spreadsheet (o_spreadsheet.Spreadsheet) and Model (o_spreadsheet.Model)

If you use an alternative, like the esm version then you might want to follow the same strategy we do to use the library in Odoo: https://github.com/odoo/odoo/blob/master/addons/spreadsheet/static/src/o_spreadsheet/odoo_module.js

Note that the library requires some dependencies to work properly, namely those found in here. Don't forget to add them as well.

rrahir avatar Aug 06 '24 13:08 rrahir

I just saw that dberardo-com provided an example of pseudo-code for his React component here, it might help as well? https://github.com/odoo/o-spreadsheet/issues/3249#issuecomment-1926387505

rrahir avatar Aug 06 '24 13:08 rrahir