This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19
VP EXPORT DOCUMENT

VP EXPORT DOCUMENT 


 

VP EXPORT DOCUMENT ( vpAreaName ; filePath {; paramObj} ) 
Parameter Type   Description
vpAreaName  Text in 4D View Pro area form object name
filePath  Text in Pathname of the document
paramObj  Object in Export options

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. If you pass a name that does not exist, an error is returned.

In filePath, pass the destination path and name of the document to be exported. You can specify the document format by including its extension, 4D View Pro (".4vp"), Microsoft Excel (".xlsx"), or PDF (".pdf") after the document's name. If you pass only the document name, it will be saved at the same level as the 4D structure file with the default ".4vp" extension.

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.

 

PropertyTypeDescription
formattext(optional) When present, designates the exported file format: ".4vp" (default), ".xlsx", or ".pdf". You can pass a constant from the 4D View Pro Constants theme in the format parameter. In this case, 4D adds the appropriate extension to the file name if needed.

The following formats are supported:

Constant Value Comment
vk 4D View Pro format .4VP 4D View Pro format (default format)
vk MS Excel format .xlsx Microsoft Excel format
vk pdf format .pdf

PDF format

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 only (optional) - Password used to protect the MS Excel document
formulaobjectCallback method to be launched when the export has completed. Using a callback method is necessary when the export is asynchronous (which is the case for PDF and Excel formats) if you need some code to be executed after the export. The callback method must be used with the Formula command (see below for more information).
valuesOnlybooleanSpecifies that only the values from formulas (if any) will be exported.
includeFormatInfobooleanTrue to include formatting information, false otherwise (default is true). Formatting information is useful in some cases, e.g. for export to SVG. On the other hand, setting this property to false allows reducing export time.
sheetIndexnumberPDF only (optional) - Index of sheet to export (starting from 0). -2=all visible sheets (default), -1=current sheet only
pdfOptionsobjectPDF only (optional) - Options for the 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.
<customProperty>anyAny custom property that will be available through the $3 parameter in the callback method.

 

  • Notes about Excel format
    • When exporting a 4D View Pro document into a Microsoft Excel-formatted file, some settings may be lost. For example, 4D methods and formulas are not supported by Excel. You can verify other settings with this list from GrapeCity. 
    • 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
    • When exporting a 4D View Pro document in PDF, the fonts used in the document are automatically embedded in the PDF file. Only OpenType fonts (.OTF or .TTF files) having a Unicode map can be embedded. If no valid font file is found for a font, a default font is used instead. 
    • 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. 

When including the optional paramObj parameter, the VP EXPORT DOCUMENT command allows you to use the Formula command to call a 4D method which will be executed once the export has completed. The callback method will receive the following values in local variables:

 

VariableTypeDescription
$1textThe name of the 4D View Pro object
$2textThe filepath of the exported 4D View Pro object
$3objectA reference to the command's paramObj
$4objectAn object returned by the method with a status message
.successbooleanTrue if export with success, False otherwise.
.errorCodeintegerError code. May be returned by 4D or JavaScript.
.errorMessagetextError message. May be returned by 4D or JavaScript.

You want to export the contents of the "VPArea" area to a 4D View Pro document on disk:

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

You want to export the current sheet in PDF:

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

You want to export a 4D View Pro document in ".xlsx" format and call a method that will launch Microsoft Excel with the document open once the export has completed:

 $params:=New object
 $params.formula:=Formula(AfterExport)
 $params.format:=vk MS Excel format //".xlsx"
 $params.valuesOnly:=True
 
 VP EXPORT DOCUMENT("ViewProArea";"c:\\tmp\\convertedfile";$params)

AfterExport method:

 C_TEXT($1;$2)
 C_OBJECT($3;$4)
 $areaName:=$1
 $filePath:=$2
 $params:=$3
 $status:=$4
 
 If($status.success=False)
    ALERT($status.errorMessage)
 Else
    LAUNCH EXTERNAL PROCESS("C:\\Program Files\\Microsoft Office\\Office15\\excel "+$filePath)
 End if



See also 

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

 
PROPERTIES 

Product: 4D
Theme: 4D View Pro Language
Number: 905255

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R4
Modified: 4D v17 R3
Modified: 4D v18

 
ARTICLE USAGE

4D View Pro Reference ( 4D v19)