-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImport_Data.gs
More file actions
47 lines (41 loc) · 1.38 KB
/
Copy pathImport_Data.gs
File metadata and controls
47 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @file Import_Data.gs
* @description Módulo responsável pela importação de dados externos p/ o sistema.
*
* @module Import_Data
* @namespace Import_Data
* @author EnSiSanar Dev Team
* @version 1.1.0
* @since 2026-04-16
* @requires Logger_System
* @requires DB_Core
*/
const Import_Data = {
_MODULE_NAME: 'Import_Data',
init: function() {
try {
Logger_System.info(`[${this._MODULE_NAME}] inicializado com sucesso.`);
} catch (e) {
Logger.log(`[Import_Data.init] Erro ao inicializar: ${e.message}`);
}
},
importFromCSV: function(csvString, targetSheet) {
try {
const sheet = DB_Core.getSheet(targetSheet);
if (!sheet) throw new Error('Aba não encontrada.');
const lines = csvString.split('\n');
const rows = lines.map(line => line.split(','));
if (rows.length > 0) {
sheet.getRange(sheet.getLastRow() + 1, 1, rows.length, rows[0].length).setValues(rows);
}
Logger_System.info(`[Import_Data] Foram importadas ${rows.length} linhas para ${targetSheet}.`);
return { success: true, importedRows: rows.length };
} catch (e) {
Logger_System.error(`[Import_Data.importFromCSV] Erro: ${e.message}`);
return { success: false, message: e.message };
}
}
};
function initImportData() {
Import_Data.init();
}