4D Blog

Home Tips Create a 4D View Pro document offscreen

Create a 4D View Pro document offscreen

July 9, 2018

Tips

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
$doc.dateModified:=Timestamp // modification date
$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.

starter example

In the example bellow we write “Hello 4D View Pro!” in the first cell of your document:

// Create the document
$doc:=New object("version";1;"dateCreation";Timestamp;"dateModified";Timestamp)
$doc.spreadJS:=New object("version";"11.0.0";"sheets";New object)
//
// Creation of the first sheet
$sheet:=New object("name";"Sheet1";"rowCount";100;"columnCount";20)
$doc.spreadJS.sheets[$sheet.name]:=$sheet
//
// Fill first sheet cells
$sheet.data:=New object("dataTable";New object)
$sheet.data.dataTable["0"]:=New object // first row
$sheet.data.dataTable["0"]["0"]:=New object("value";"Hello 4D View Pro!") // set A1
$sheet.data.dataTable["0"]["1"]:=New object("value";42) // set B1
//
VP IMPORT FROM OBJECT ("ViewProArea";$doc)

Advanced example

In the example database, you can see how to quickly 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.

Discuss

Tags 4D View Pro, Spreadsheet, v17

Latest related posts

  • September 15, 2025

    Find the right spot in your 4D Write Pro document with AI

  • September 2, 2025

    Intelligent 4D Write Pro document analysis with AI

  • August 25, 2025

    ORDA – Constructor and touched event – Detailed behaviour through a network

Fabrice Mainguené
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.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy