Aller au contenu principal
Version: 20 R5 BETA

VP EXPORT DOCUMENT

Historique
ReleaseModifications
20 R2Support of .sjs documents

VP EXPORT 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'export

Description

The VP EXPORT DOCUMENT command exports the 4D View Pro object attached to the 4D View Pro area vpAreaName to a document on disk according to the filePath and paramObj parameters.

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 destination path and name of the document to be exported. Si vous ne spécifiez pas de chemin, le document sera sauvegardé au même niveau que le dossier Projet.

Vous pouvez préciser le format du document en incluant une extension après son nom :

  • 4D View Pro (".4vp")
  • Microsoft Excel (".xlsx")
  • PDF (".pdf")
  • CSV (".txt", or ".csv")
  • SpreadJS document (".sjs")

If the extension is not included, but the format is specified in paramObj, the exported file will have the extension that corresponds to the format, except for the CSV format (no extension is added in this case).

The optional paramObj parameter allows you to define multiple properties for the exported 4D View Pro object, as well as launch a callback method when the export has completed.

PropriétéTypeDescription
formattext(optionnel) S'il est présent, désigne le format du fichier exporté : ".4vp" (par défaut), ".csv", ".xlsx", ".pdf", ou ".sjs". You can use the following constants:
  • vk 4D View Pro format
  • vk csv format
  • vk MS Excel format
  • vk pdf format
  • vk sjs format
  • 4D adds the appropriate extension to the file name if needed. If the format specified doesn't correspond with the extension in filePath, it will be added to the end of filePath. If a format is not specified and no extension is provided in filePath, the default file format is used.
    passwordtextMicrosoft Excel uniquement (optionnel) - Mot de passe utilisé pour protéger le document MS Excel
    formula4D.FunctionMéthode callback à lancer lorsque l'export est terminé. L'utilisation d'une méthode callback est nécessaire lorsque l'export est asynchrone (ce qui est le cas pour les formats PDF et Excel) si vous avez besoin d'un code à exécuter après l'export. The callback method must be passed with the Formula command. See Passing a callback method (formula).
    valuesOnlybooleanPrécise que seules les valeurs issues de formules (le cas échéant) seront exportées.
    includeFormatInfobooleanTrue pour inclure les informations de formatage, sinon False (True par défaut). Les informations de formatage sont utiles dans certains cas, par exemple pour un export en SVG. On the other hand, setting this property to false allows reducing export time.
    includeBindingSourceboolean4DVP et Microsoft Excel uniquement. True (par défaut) pour exporter les valeurs du contexte de données courant en tant que valeurs de cellule dans le document exporté (les contextes de données eux-mêmes ne sont pas exportés). Sinon Faux. La liaison de cellule est toujours exportée. For data context and cell binding management, see VP SET DATA CONTEXT and VP SET BINDING PATH.
    sheetnumberPDF uniquement (optionnel) - Numéro de la feuille à exporter (débute à 0). -2=all visible sheets (default), -1=current sheet only
    pdfOptionsobjectPDF only (optional) - Options for pdf export

    PropertyTypeDescription
    creatortextname of the application that created the original document from which it was converted.
    titletexttitle of the document.
    authortextname of the person who created that document.
    keywordstextkeywords associated with the document.
    subjecttextsubject of the document.

    csvOptionsobjectCSV only (optional) - Options for csv export

    PropertyTypeDescription
    rangeobjectRange object of cells
    rowDelimitertextRow delimiter. Default: "\r\n"
    columnDelimitertextColumn delimiter. Default: ","

    sjsOptionsobjectSJS only (optional) - Options for sjs export

    PropertyTypeDescription
    includeAutoMergedCellsbooleanwhether to include the automatically merged cells, default is false.
    includeBindingSourcebooleanwhether to include the binding source, default is true.
    includeCalcModelCachebooleanwhether to include the extra data of calculation. Can be faster when open the file with those data, default is false.
    includeEmptyRegionCellsbooleanwhether to include any empty cells (cells with no data or only style) outside the used data range, default is true.
    includeFormulasbooleanwhether to include the formulas, default is true.
    includeStylesbooleanwhether to include the style, default is true.
    includeUnusedNamesbooleanwhether to include the unused custom names, default is true.
    saveAsViewbooleanwhether to apply the format string to exporting values, default is false.

    \<customProperty>anyPropriété personnalisée qui sera disponible via le paramètre $3 dans la méthode de callback.

    Notes about Excel format:

    • Lors de l'export d'un document 4D View Pro en un fichier au format Microsoft Excel, certains paramètres peuvent être perdus. Par exemple, les méthodes et formules 4D ne sont pas prises en charge par Excel. You can verify other settings with this list from SpreadJS.
    • Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.

    Notes about PDF format:

    • Lors de l'export d'un document 4D View Pro en un fichier au format PDF, les polices utilisées dans le document sont automatiquement intégrées dans le fichier PDF. Seules les polices OpenType (fichiers .OTF ou .TTF) ayant une table Unicode peuvent être intégrées. Si aucun fichier de polices valide n'est trouvé pour une police, une police par défaut est utilisée à sa place.
    • Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.

    Notes about CSV format:

    • Lors de l'export d'un document 4D View Pro en un fichier au format PDF, certains paramètres peuvent être perdus, car seuls le texte et les valeurs sont sauvegardés.
    • Toutes les valeurs sont enregistrées sous la forme de chaînes entre guillemets. For more information on delimiter-separated values, see this article on Wikipedia.
    • Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.

    Notes about SpreadJS file format:

    • SpreadJS files are zipped files.
    • Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.

    Once the export operation is finished, VP EXPORT DOCUMENT automatically triggers the execution of the method set in the formula property of the paramObj, if used.

    Passer une méthode callback (formula)

    When including the optional paramObj parameter, the command allows you to use the Formula command to call a 4D method which will be executed once the export has completed. La méthode callback recevra les valeurs suivantes dans des variables locales :

    ParamètresTypeDescription
    param1textNom de l'objet 4D View Pro
    param2textChemin d'accès de l'objet 4D View Pro exporté
    param3objectA reference to the command's paramObj
    param4objectObjet retourné par la méthode avec un message de statut
    .successbooleanVrai si l'export est réussi, Faux sinon.
    .errorCodeentierCode d'erreur.
    .errorMessagetextMessage d'erreur.

    Exemple 1

    Vous souhaitez exporter le contenu de la zone "VPArea" vers un document 4D View Pro sur le disque :

    var $docPath: Text

    $docPath:="C:\\Bases\\ViewProDocs\\MyExport.4VP"
    VP EXPORT DOCUMENT("VPArea";$docPath)
    //MyExport.4VP is saved on your disk

    Exemple 2

    Vous souhaitez exporter la feuille courante au format PDF :

    var $params: Object
    $params:=New object
    $params.format:=vk pdf format
    $params.sheet:=-1
    $params.pdfOptions:=New object("title";"Annual Report";"author";Current user)
    VP EXPORT DOCUMENT("VPArea";"report.pdf";$params)

    Exemple 3

    Vous souhaitez exporter un document 4D View Pro au format ".xlsx" et appeler une méthode qui lance Microsoft Excel avec le document ouvert une fois que l'export est terminé :

     $params:=New object
    $params.formula:=Formula(AfterExport)
    $params.format:=vp MS Excel format //".xlsx"
    $params.valuesOnly:=True

    VP EXPORT DOCUMENT("ViewProArea";"c:\\tmp\\convertedfile";$params)

    AfterExport method:

     #DECLARE($areaName : Text ; $filePath : Text ; $params : Object ; $status : Object )

    If($status.success=False)
    ALERT($status.errorMessage)
    Else
    LAUNCH EXTERNAL PROCESS("C:\\Program Files\\Microsoft Office\\Office15\\excel "+$filePath)
    End if

    Exemple 4

    You want to export the current sheet to a .txt file with pipe-separated values:

    example-export-csv

    var $params : Object
    $params:=New object
    $params.range:=VP Cells("ViewProArea";0;0;2;5)
    $params.rowDelimiter:="\n"
    $params.columnDelimiter:="|"
    VP EXPORT DOCUMENT("ViewProArea";"c:\\tmp\\data.txt";New object("format";vk csv format;"csvOptions";$params))

    Voici le résultat :

    example-export-csv

    Voir également

    VP Convert to picture
    VP Export to object
    VP IMPORT DOCUMENT
    VP Print