4D Blog

Home Product Use collections to write and read in 4D View Pro

Use collections to write and read in 4D View Pro

July 25, 2019

Product

If you need to read or write hundreds of different values or formulas, you can do it faster, easier, and at the same time by using collections. New commands are available for this: VP SET VALUES, VP Get values, VP SET FORMULAS, and VP Get formulas.

Read/write values

To set values in cells, create a collection where each element represents a row. Each row is a collection of cell values to be set in the columns. See the example below:

$values:=New collection

// First row
$values.push(New collection("ID"; "Monday";"Tuesday";"Wednesday";"Thursday"; "Friday";"Saturday";"Sunday"))
// Second row
$values.push(New collection(1;1778;5656;22269;2964;20890;32189;26212))

// Write all values in the document
VP SET VALUES (VP Cell ("ViewProArea";1;1);$values)

To retrieve the values, simply pass a range that includes the cells you want to VP Get values. The command returns the values in the corresponding collections.

$values:=VP Get values (VP Cells ("ViewProArea";1;1;8;2))

blank

See the commands in action in this HDI:

HDI: Read and Write Cell Values 

Read/write formulas

The same concept also applies to formulas. To set formulas in the cells of your 4D View Pro document, you need to create a range to designate the first cell. Then create the desired collections and pass them as parameters to VP SET FORMULAS:

$formulas:=New collection

// First row

$formulas.push(New collection("myMethod(I3)";"MAX(A1,B2,C3,D4,E5)"))
// Second row
$formulas.push(New collection("SUM(C5:I5)";"AVERAGE(C5:I5)"))

// Set the cells with the formulas
VP SET FORMULAS (VP Cell ("ViewProArea";5;15);$formulas)

To get formulas, just pass a range that includes the cells with the formulas to the VP Get formulas command:

$formulas:=VP Get formulas (VP Cells ("ViewProArea";5;15;2;3))

Discuss

Tags 4D View Pro, Collections, Document creation, Formula, Spreadsheet, v17 R6, v18

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

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

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 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