Aller au contenu principal
Version: 20 R5 BETA

VP IMPORT DOCUMENT

Historique
ReleaseModifications
20 R2Support of .sjs documents

VP IMPORT DOCUMENT ( vpAreaName : Text ; filePath : Text { ; paramObj : Object} )

ParamètresTypeDescription
vpAreaNameText->Nom d'objet formulaire zone 4D View Pro
filePathText->Chemin d'accès du document
paramObjObject->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ètresTypeDescription
formula4D.FunctionUne 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).
passwordtextMicrosoft Excel uniquement (optionnel) - Mot de passe utilisé pour protéger un document Microsoft Excel.
csvOptionsobjectoptions d'import csv
rangeobjectPlage 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.
rowDelimitertextDélimiteur de ligne. S'il n'est pas défini, le délimiteur est automatiquement déterminé par 4D.
columnDelimitertextDélimiteur de colonne. Par défaut : ","
sjsOptionsobjectoptions d'import sjs
calcOnDemandbooleanIndique si les formules doivent être calculées uniquement lorsqu'elles sont demandées, la valeur par défaut est faux.
dynamicReferencesbooleanIndique si les fonctions doivent être calculées avec des références dynamiques, la valeur par défaut est vrai.
fullRecalcbooleanIndique si le calcul doit être effectué après le chargement des données json, la valeur par défaut est faux.
includeFormulasbooleanWhether to include the formulas when loading, default is true.
includeStylesbooleanWhether to include the styles when loading, default is true.
includeUnusedStylesbooleanWhether to include the unused name styles when converting excel xml to the json, default is true.
openModeentier
  • 0 (normal): normal open mode, without lazy and incremental. When opening file, UI and UI event could be refreshed and responsive at specific time points.
  • 1 (lazy): lazy open mode. When opening file, only the active sheet will be loaded directly. Other sheets will be loaded only when they are be used.
  • 2 (incremental): incremental open mode. When opening file, UI and UI event could be refreshed and responsive directly.
  • Notes
    • 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:

    example-import-csv

    $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: example-import-csv

    Voir également

    VP EXPORT DOCUMENT
    VP NEW DOCUMENT