KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Workaround: 4D View Pro limits document export to 1000 rows
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: September 12, 2023

By default, a View Pro (VP) document starts out with 100 columns (the 100th column is named "CV") and 1000 rows. Typically, there is no limit to the number of rows and columns when working with a spreadsheet, allowing for big data processing.

However, when working with spreadsheets larger than the default size, you may find yourself in the following situation. When exporting the spreadsheet as a document—especially in the context of an offscreen area—the exported file only contains data from the first 1000 rows (and/or first 100 columns).

To combat this, you must ensure that the sheet in the VP Area has the number of rows and columns explicitly set before importing any data. This is done using the VP SET ROW COUNT and VP SET COLUMN COUNT commands.

For example, you can first check if the collection your are importing into the VP area has more than 1000 items (corresponding to the 1000 rows). If that is the case, increase the size of the sheet by using the VP SET ROW COUNT command:

// declare variables
var $col : Collection
var $vpArea : Text
var $exportParams : Object

$vpArea:="ViewProArea"

// create collection to import into 4D View Pro Area
$col:=New collection
// ... populate the collection here ...

// set row count
If ($col.length>1000)
   VP SET ROW COUNT($vpArea; $col.length)
End if

// import the data into the sheet, starting at cell A1
VP SET VALUES(VP Cell($vpArea; 0; 0); $col)

// export as PDF document
$exportParams:=New object
$exportParams.format:=vk pdf format
VP EXPORT DOCUMENT($vpArea; "sample.pdf"; $exportParams)

The same logic can be applied to situations where the spreadsheet would require more than 100 columns. In this case, just use the VP SET COLUMN COUNT command.