Do you need to create a 4D View Pro document using code, without any user interface? It’s possible! Because 4D View Pro documents are objects, it’s very easy to create off-screen documents. You can create a new document in a variable of object type and manipulate it through its properties. When your document is ready, you can register it in your database, in a file, or display it directly in a 4D View Pro area.
Creating a 4D View Pro document is quite simple.
First, create an object with the following structure:
$doc.version:=1 // version [mandatory]
$doc.dateCreation:=Timestamp // creation date [mandatory]
$doc.dateModified:=Timestamp // modification date [mandatory]
$doc.spreadJS:=New object // spreadJS [mandatory]
$doc.meta:=New object("comment";"4D - How do I") // optional metadata
This object contains:
- Internal information for 4D: document version
- Developer information: metadata, creation, and modification dates
- Document structure and data: data to be passed in the spreadJS property.
Once your structure is ready, complete the spreadJS property. It’s an object which contains, among other things, spreadsheet information, data, cell styles, formulas, etc.
In the example database, you can see how to quicky and easily create a simple document off-screen.
To assist you with the creation of more complicated documents, you can refer to the JSON schema of SpreadJS documents.