Create a 4D View Pro document offscreen

Automatically translated from English

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:=New object
$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.

Off-screen creation of a 4D View Pro doc

To assist you with the creation of more complicated documents, you can refer to the JSON schema of SpreadJS documents.

Fabrice Mainguené

• Product Owner •

Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.

After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.