Skip to main content

Import Cells from xlsx

Get a metadata from db table​

Read the table structure from database and prepare the metadata for import

Syntax:

var dbTableId = utils.createDbTableMetadata(Long datasourceId, String tableName);
ArgumentDescription
datasourceIdoptional parameter (can be null); it defines the additional datastore to use
tableNametable name

Update the table metadata​

Update the table metadata if the table structure are changed

Syntax:

utils.updateDbTableMetadata(Logn dbTableId);
ArgumentDescription
dbTableIdid of table metadata

Create value for imports​

This function create the metadata for import. Prepare the data from table and read the xlsx file for values.

Syntax:

var valueImportId = utils.createValueImports(
Long dbTableId,
Long directoryId,
String fileName,
String description,
String note,
String inputData,
Long breakOnColumnsEmpty,
Long breakOnRowsEmpty
);
ArgumentDescription
dbTableIdid of table metadata for import
directoryIdid of the directory where to search the file
fileNamefile name
descriptiondescription for import (can be null)
notenote for import (can be null)
inputDatastring in json format for data in import (can be null)
breakOnColumnsEmptynumber of empty cells in row to stop reading values in the sheet (default 5) (can be null)
breakOnRowsEmptynumber of empty rows to stop reading values in the sheet (default 5) (can be null)

Duplicate value import​

This function duplicate the import metadata and read the values from the old file or from the new file.

Syntax:

var valueImportId = utils.duplicateValueImports(
Long valueImportId,
Long directoryId,
String fileName,
String description,
String note,
String inputData,
Long breakOnColumnsEmpty,
Long breakOnRowsEmpty,
Boolean ignoreSheet
);
ArgumentDescription
valueImportIdid of import to duplicate
directoryIdid of the directory where to search the file; can bel null if you want read the old file
fileNamefile name; can bel null if you want read the old file
descriptiondescription for import (can be null)
notenote for import (can be null)
inputDatastring in json format for data in import (can be null)
breakOnColumnsEmptynumber of empty cells in row to stop reading values in the sheet (default 5) (can be null)
breakOnRowsEmptynumber of empty rows to stop reading values in the sheet (default 5) (can be null)
ignoreSheetignore the deleted sheet and remove the references

Import Cells from Excel File​

This function import the mapped cells value from excel into the database table.

Syntax:

var result = utils.importCellsFromExcelFile(
Long directoryId,
String fileName,
Long valueImportId,
Map fieldsData,
Map inputData,
Boolean separatedTransaction
);
ArgumentDescription
valueImportIdid of import to duplicate
directoryIdid of the directory where to search the file
fileNamefile name
valueImportIdid of defined import
fieldsDataother value of fields table to valorize in import
inputDatastring in json format for data in import (can be null)
separatedTransactionflag true|false indicating whether the SQL query must be executed in a separated database transaction or within the current one

Check cells from excel file​

This function check the mapped cells from excel and verify the mandatory values, the format etc

Syntax:

var result = utils.checkCellsWithMetadataForImport(
Long directoryId,
String fileName,
Long valueImportId
);
ArgumentDescription
valueImportIdid of import to duplicate
directoryIdid of the directory where to search the file
fileNamefile name
valueImportIdid of defined import

Export areas from excel to new file excel​

This function copies the cells value of an area to the specified area in a new file

Syntax:

var result = utils.exportFromExcelFile(
Long sourceDirId,
String sourceFileName,
Long destDirId,
String destFileName,
List areas
);
ArgumentDescription
sourceDirIdid of the source file directory
sourceFileNamesource file name (xlsx)
destDirIdid of the destination file directory
destFileNamedestination file name (xlsx)
areaslist of cells area to export

Example

var result = utils.exportFromExcelFile(
9, //Long sourceDirID
'sourceFileName.xlsx', //String sourceFileName
19, //Long destDirId
'destFileName.xlsx', //String destFileName
[
\{
sourceSheetName: 'Sheet1',
sourceCoordinates: 'A1:C3',
destSheetName: 'SheetDest1',
destCoordinate: 'A1:C3'
\},
\{
sourceSheetName: 'Sheet2',
sourceCoordinates: 'A11:C15',
destSheetName: 'SheetDest2',
destCoordinate: 'A1:C5'
\}
]
);

Export areas from excel to Google Spreadsheet​

This function copies the cells value of an area to the specified area in a Google Spreadsheet

Syntax:

var result = utils.exportFromExcelFile(
Long sourceDirId,
String sourceFileName,
String spreadsheetId,
List areas
);
ArgumentDescription
sourceDirIdid of the source file directory
sourceFileNamesource file name (xlsx)
spreadsheetIdid of the Google Spreadsheet
areaslist of cells area to export

Example

var result = utils.exportFromExcelFile(
9, //Long sourceDirID
'sourceFileName.xlsx', //String sourceFileName
'XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX', //String spreadsheetId
[
\{
sourceSheetName: 'Sheet1',
sourceCoordinates: 'A1:C3',
destSheetName: 'SheetDest1',
destCoordinate: 'A1:C3'
\},
\{
sourceSheetName: 'Sheet2',
sourceCoordinates: 'A11:C15',
destSheetName: 'SheetDest2',
destCoordinate: 'A1:C5'
\}
]
);

Disable Import​

This function logically disables an import definition

Syntax:

var result = utils.disableValueImport(
Long valueImportId
);
ArgumentDescription
valueImportIdid of the import definition

Delete Import​

This function definitively cancels an import

Syntax:

var result = utils.deleteValueImport(
Long valueImportId
);
ArgumentDescription
valueImportIdid of the import definition