4D View Pro: join two View Pro objects?

Is it possible to join two 4D View Pro objects?
Eg VP A having three sheets and VP B with 5 sheets join to one VP having 8 sheets.

This could be really easy, just a few lines of code to move the objects from the “sheets” attribute of document A to document B, and then you have a document B with all the sheets.
The important points to take into consideration:

  • You can’t have two sheets with the same name in the same document, so you should rename the sheet you copy if necessary.
  • If you use stylesheets, it will be necessary to merge also the “namedStyles” array to make sure you have all the needed stylesheets.

Maybe I forgot some points, but there is no reasons it won’t work.

1 Like

Thanks for the heads up, Francois. I got it working in about 60 lines of code (but did not handle stylesheets yet). A few caveats though:

  • if a View Pro object has only one sheet, the property sheetCount is absent in the spreadJS object
  • the sheet list is not an array of objects, but an object containing the sheet objects with the sheet name as property name
  • to avoid duplicates the sheet.name must get a unique value and the sheet object property must be set accordingly
  • the sheet index must be updated to the final position of the sheet in the sheet list (also unique)

Good to see you succeed in implementing it ! :slight_smile: