KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Get Sheet Name in 4D View Pro
PRODUCT: 4D View Pro | VERSION: 19 | PLATFORM: Mac & Win
Published On: October 12, 2021

As of v19R2, the command VP Get sheet name can be used to find out the sheet names of a spreadsheet in 4D View Pro. However for database applications on versions prior to v19R2, the utility method below can be used to find the sheet names. Note the first sheet index begins at 0. Many of the spreadsheet attributes can be retrived by exporting the View Pro area to an object and then parsing the object attributes.

//=========================
//Method: Util_vpGetSheetName
// $0 (Text) - Name of sheet
// $1 (Text) - 4D View Pro area name
// $2 (Longint) - index of sheet name to find
//=========================
C_TEXT($0;$1;$areaName_t;$sheet_t;$foundSheet_t)
C_LONGINT($2;$sheetIndex_l)
C_OBJECT($vp_o)

If (Count parameters=2)
   $areaName_t:=$1
   $sheetIndex_l:=$2

   $vp_o:=VP Export to object($areaName_t)
   For each ($sheet_t;$vp_o.spreadJS.sheets) Until ($foundSheet_t#"")
      If ($vp_o.spreadJS.sheets[$sheet_t].index=$sheetIndex_l)
         $foundSheet_t:=$sheet_t
      End if
   End for each

   $0:=$foundSheet_t
End if


Example of calling this method.

$firstSheet_t:=Util_vpGetSheetName("MyVPArea1";0) //Finds name of first sheet