VP IMPORT DOCUMENT
História
Release | Mudanças |
---|---|
20 R2 | Suporte de documentos .sjs |
VP IMPORT DOCUMENT ( vpAreaName : Text ; filePath : Text { ; paramObj : Object} )
Parâmetro | Tipo | Descrição | ||
---|---|---|---|---|
vpAreaName | Text | -> | Nome de objeto formulário área 4D View Pro | |
filePath | Text | -> | Caminho do documento | |
paramObj | Object | -> | Opções de importação |
Descrição
O comando VP IMPORT DOCUMENT
importa e exibe o documento designado por filePath na área 4D View Pro vpAreaName. O documento importado substitui qualquer dado já inserido na área
Em vpAreaName, passe o nome da área 4D View Pro. Se passar um nome que não existe, é devolvido um erro.
Em filePath, passe o caminho de destino e o nome do documento a ser importado. São suportados os seguintes formatos:
- Os documentos 4D View Pro (extensão ".4vp")
- Microsoft Excel (extensão ".xlsx")
- documentos textos (extensão ".txt", ".csv", o documento deve ser em utf-8)
- Documentos SpreadJS (extensão ".sjs")
If the document extension is not a recognized extension, such as .4vp
or .xlsx
, the document is considered a text document. Deve passar uma rota completa, a não ser que o documento esteja localizado no mesmo nível que a pasta Project, em cujo caso pode passar apenas seu nome.
An error is returned if the filePath
parameter is invalid, or if the file is missing or malformed.
O parâmetro opcional paramObj permite definir as propriedades do documento importado:
Parâmetro | Tipo | Descrição | |
---|---|---|---|
formula | 4D. Function | Um método de retorno de chamada a ser iniciado quando a importação for concluída. Você deve usar uma fórmula retornada pelo comando Formula . Veja Passando um método de callback (fórmula). | |
senha | text | Somente Microsoft Excel (opcional) - Senha usada para proteger o documento do MS Excel. | |
csvOptions | object | opções para importação csv | |
range | object | O intervalo de células que contém a primeira célula onde os dados serão escritos. Se o intervalo especificado não é um intervalo de células, só a primeira célula do intervalo é usada. | |
rowDelimiter | text | Delimitador de linha. Se não estiver presente, o delimitador é automaticamente determinado por 4D. | |
columnDelimiter | text | Delimitador de coluna. O padrão: "," | |
sjsOptions | object | opções para importação de sjs | |
calcOnDemand | boolean | Se as fórmulas devem ser calculadas somente quando forem exigidas; padrão=falso. | |
dynamicReferences | boolean | Se deve calcular funções com referências dinâmicas; o padrão é true. | |
fullRecalc | boolean | Para decidir se calcula depois do carregamento do dado json, falso por padrão | |
includeFormulas | boolean | Se deve incluir as fórmulas ao carregar; o padrão é true. | |
includeStyles | boolean | Se os estilos devem ser incluídos no carregamento; o padrão é true. | |
includeUnusedStyles | boolean | Se deve incluir os estilos de nome não utilizados ao converter o xml do Excel em json; o padrão é true. | |
openMode | integer | ||
excelOptions | object | Excel only (optional) - Options for Excel export | |
includeStyles | boolean | Whether to include the style when importing, default true. | |
includeFormulas | boolean | Whether to include the formula when importing, default true. | |
frozenColumnsAsRowHeaders | boolean | Whether to treat the frozen columns as row headers when importing, default false. | |
frozenRowsAsColumnHeaders | boolean | Whether to treat the frozen rows as column headers when importing, default false. | |
fullRecalc | boolean | Para decidir se calcula depois do carregamento do dado json, falso por padrão | |
dynamicReferences | boolean | Whether to calculate functions with dynamic reference, default true. | |
calcOnDemand | boolean | Whether to calculate formulas only when they are demanded, default false. | |
includeUnusedStyles | boolean | Whether to include the unused name style when converting excel xml to the json, default true. | |
senha | text | The password to open the workbook. | |
openMode | text | The open mode of normal, lazy and incremental. Por padrão, é normal. |
- Importar arquivos em formatos .xslx, .csv, e .sjs é assíncrona. With these formats, you must use the
formula
attribute if you want to start an action at the end of the document processing. - Quando importar um arquivo formatado em Excel em um documento 4D View Pro, algumas configurações podem ser perdidas. 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
- Usando o objeto excelOptions é recomendado ao importar o formato ".xlsx". Make sure to not mix this object with legacy first level property password to avoid potiental issues.
Exemplo 1
Se quiser importar um documento 4D View Pro armazenado no disco quando o formulário for aberto:
var $docPath : text
If(Form event code=On VP Ready) //4D View Pro area loaded and ready
$docPath:="C:\\Bases\\ViewProDocs\\MyExport.4VP"
VP IMPORT DOCUMENT("VPArea";$docPath)
End if
Exemplo 2
Você deseja importar um documento do Microsoft Excel protegido por senha para uma área do 4D View Pro:
//Import code
var $o:={}
$o.formula:=Formula(myImport)
$excelOptions:={includeStyles:false;includeFormulas:true;password:"excel123"}
$o.excelOptions:=$excelOptions
VP IMPORT DOCUMENT("ViewProArea";"c:\\tmp\\excelfile.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
Exemplo 3
Você deseja importar um arquivo .txt
que usa uma vírgula (",") como delimitador:
var $params:={}
$params.range:=VP Cells("ViewProArea";0;0;2;5)
VP IMPORT DOCUMENT("ViewProArea";"c:\\import\\my-file.txt";New object("csvOptions";$params))
Aqui está o resultado:
Veja também
VP EXPORT DOCUMENT
VP NEW DOCUMENT
4D View Pro: Excel import/export update (blog post)