VP IMPORT DOCUMENT
Historique
Release | Modifications |
---|---|
20 R2 | Support of .sjs documents |
VP IMPORT DOCUMENT ( vpAreaName : Text ; filePath : Text { ; paramObj : Object} )
Paramètres | Type | Description | ||
---|---|---|---|---|
vpAreaName | Text | -> | Nom d'objet formulaire zone 4D View Pro | |
filePath | Text | -> | Chemin d'accès du document | |
paramObj | Object | -> | Options d'import |
Description
The VP IMPORT DOCUMENT
command imports and displays the document designated by filePath in the 4D View Pro area vpAreaName. Le document importé remplace toutes les données déjà présentes dans la zone.
In vpAreaName, pass the name of the 4D View Pro area. Si vous passez un nom inexistant, une erreur est retournée.
In filePath, pass the path and name of the document to be imported. Les formats suivants sont pris en charge :
- Les documents 4D View Pro (extension ".4vp")
- Microsoft Excel (extension ".xlsx")
- documents texte (extension ".txt", ".csv", le document doit être en utf-8)
- SpreadJS documents (extension ".sjs")
If the document extension is not a recognized extension, such as .4vp
or .xlsx
, the document is considered a text document. Vous devez passer un chemin d'accès complet, sauf si le document est situé au même niveau que le dossier Project, auquel cas vous pouvez simplement passer son nom.
An error is returned if the filePath
parameter is invalid, or if the file is missing or malformed.
The optional paramObj parameter allows you to define properties for the imported document:
Paramètres | Type | Description | |
---|---|---|---|
formula | 4D.Function | Une méthode callback à lancer lorsque l'import est terminé. You must use a formula returned by the Formula command. See Passing a callback method (formula). | |
password | text | Microsoft Excel uniquement (optionnel) - Mot de passe utilisé pour protéger un document Microsoft Excel. | |
csvOptions | object | options d'import csv | |
range | object | Plage de cellules contenant la première cellule dans laquelle les données seront saisies. Si la plage spécifiée n'est pas une plage de cellules, seule la première cellule de la plage est utilisée. | |
rowDelimiter | text | Délimiteur de ligne. S'il n'est pas défini, le délimiteur est automatiquement déterminé par 4D. | |
columnDelimiter | text | Délimiteur de colonne. Par défaut : "," | |
sjsOptions | object | options d'import sjs | |
calcOnDemand | boolean | Indique si les formules doivent être calculées uniquement lorsqu'elles sont demandées, la valeur par défaut est faux. | |
dynamicReferences | boolean | Indique si les fonctions doivent être calculées avec des références dynamiques, la valeur par défaut est vrai. | |
fullRecalc | boolean | Indique si le calcul doit être effectué après le chargement des données json, la valeur par défaut est faux. | |
includeFormulas | boolean | Whether to include the formulas when loading, default is true. | |
includeStyles | boolean | Whether to include the styles when loading, default is true. | |
includeUnusedStyles | boolean | Whether to include the unused name styles when converting excel xml to the json, default is true. | |
openMode | entier |
- Importing files in .xslx, .csv, and .sjs formats is asynchronous. With these formats, you must use the
formula
attribute if you want to start an action at the end of the document processing. - When importing a Microsoft Excel-formatted file into a 4D View Pro document, some settings may be lost. You can verify your settings with this list from SpreadJS.
- For more information on the CSV format and delimiter-separated values in general, see this article on Wikipedia
Exemple 1
Vous souhaitez importer un document 4D View Pro stocké sur le disque, à l'ouverture du formulaire :
C_TEXT($docPath)
If(Form event code=On VP Ready) //La zone 4D View Pro est chargée et prête
$docPath:="C:\\Bases\\ViewProDocs\\MyExport.4VP"
VP IMPORT DOCUMENT("VPArea";$docPath)
End if
Exemple 2
Vous souhaitez importer un document Microsoft Excel protégé par un mot de passe dans 4D View Pro :
//Import code
var $o : Object
$o:=New object
$o.password:="excel123"
$o.formula:=Formula(myImport)
VP IMPORT DOCUMENT("ViewProArea";"c:\\tmp\\excelfilefile.xlsx";$o)
//myImport callback method
#DECLARE($area : Text; $filePath : Text; $param : Object; $status : Object)
If ($status.success)
ALERT("Import successfully completed")
Else
ALERT("Error: "+$status.errorMessage)
End if
Exemple 3
You want to import a .txt
file that uses a comma (",") as delimiter:
$params:=New object
$params.range:=VP Cells("ViewProArea";0;0;2;5)
VP IMPORT DOCUMENT("ViewProArea";"c:\\import\\my-file.txt";New object("csvOptions";$params))
Here's the result: