KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Add/Remove Sheets in 4D ViewPro Programmatically
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: August 24, 2020

Adding and removing sheets in a 4D View Pro document can be done programmatically. 4D View Pro objects have a property, sheetCount, which hold information of the number of sheets the document has. This property value can be changed to add or remove sheets in a View Pro document.

An example of this is shown below. In the example, the sheetCount property of the View Pro document is set to 2. For a View Pro document that had 1 sheet previously, this will add an additional sheet. For a View Pro document that had 3 sheets previously, this will remove the last sheet.

$vp_name:="vp"
$sheets:=2
$vp_o:=VP Export to object($vp_name)
$vp_o.spreadJS.sheetCount:=$sheets
VP IMPORT FROM OBJECT($vp_name;$vp_o)