KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D View Pro Spreadsheet Instance for SpreadJS
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: April 22, 2020

The 4D View Pro area is a special 4D Web area that is running SpreadJS to provide the spreadsheet features. Since it is a web area, the WA Evaluate Javascript command can be used to run javascipt on the area. When running javascript, especially SpreadJS, the spreadsheet instance will need to be targeted to perform the functions on. For the 4D View Pro area, the spreadsheet instance can be one of two names based on which of the three UI's the area is using.


If the UI is set to "None" or "Toolbar" then the name is "spread".
If the UI is set to "Ribbon" then the name is "Utils.spread".

Below is a method to check which name the spreadsheet instance is using

C_TEXT($0)
C_TEXT($1;$vpAreaName_t)
C_TEXT($jsScript_t)
C_OBJECT($res_ob)

$vpAreaName_t:=$1
$jsScript_t:="spread;"
$res_ob:=WA Evaluate JavaScript(*;$vpAreaName_t;$jsScript_t;Is object)

If ($res_ob=Null)
   $0:="Utils.spread"
Else
   $0:="spread"
End if


It will check if an object representing the spreadsheet document is returned or not if it is then the tested name of "spread" works and the UI must be "None" or "Toolbar" if the object is Null, it can be safe to assume that the name of the spreadsheet instance is "Utils.spread" and the UI is "Ribbon".