-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.js
161 lines (91 loc) · 4.31 KB
/
renderer.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
// Requirements
const ibantools = require('ibantools');
const ExcelJS = require('exceljs');
const percent = require("percent-value");
const ibanBankCode = require('./ibanBankCode.js')
var selectedFileLocation,exportLocation
// File Inputing from index.html
const fileInput = document.getElementById('file-selector');
fileInput.onchange = () => {
const selectedFile = fileInput.files[0];
selectedFileLocation = selectedFile.path
console.log('Secilen dosya yolu: ' + selectedFileLocation)
var compLocationForExport = selectedFileLocation.split('\\')
var sliceLocationForExport = compLocationForExport.slice(0, -1)
exportLocation = sliceLocationForExport.join('\\')
}
function getData(){
var progress_bar = document.getElementById("progress-bar")
window.console = {
log: function(str){
var node = document.createElement('div');
node.className = "commandLine"
node.appendChild(document.createTextNode(str));
document.getElementById("myLog").appendChild(node);
}
}
function submitPoll() {
// Progress bar set zero.
// Starting button with app
progress_bar.innerHTML = "0%";
progress_bar.style.width = "0%";
document.getElementById("btn1").disabled = true;
}
document.getElementById("btn1").addEventListener("click", submitPoll);
console.log('App is starting. Please wait.')
var iban_ulke_kodu = 'TR'
//Read a file
var workbook = new ExcelJS.Workbook();
workbook.xlsx.readFile(selectedFileLocation).then(function () {
//Get sheet by Name
var worksheet=workbook.getWorksheet('Sheet1');
//Get Lastrow
var lastRow = worksheet.lastRow
worksheet.eachRow(function(row, rowNumber) {
if(rowNumber == 1){
// First Row is a table header.
progress_bar.innerHTML = percent(rowNumber).of(lastRow.number) + "%";
progress_bar.style.width = percent(rowNumber).of(lastRow.number) + "%";
}else{
// Other row is starting here.
progress_bar.innerHTML = percent(rowNumber).of(lastRow.number) + "%";
progress_bar.style.width = percent(rowNumber).of(lastRow.number) + "%";
console.log(percent(rowNumber).of(lastRow.number) + '%');
console.log('Row number is ' +rowNumber)
var kullaniciBilgisi = row.values
var kullaniciIban = kullaniciBilgisi[4]
const iban = kullaniciIban;
if(iban.substring(0,2) == iban_ulke_kodu){
if(ibantools.validateIBAN(iban).valid == true){
// console.log('IBAN Numarasi gecerlidir.')
var ibanCode = iban.substring(4,9)
console.log(ibanCode)
row.getCell(5).value = ibanBankCode.findIbanBankCode(ibanCode).bankName
row.getCell(6).value = 'True';
row.commit();
}else{
row.getCell(6).value = 'False';
row.getCell(7).value = ibantools.validateIBAN(iban).errorCodes;
row.commit();
}
}else{
row.getCell(5).value = 'False';
row.getCell(6).value = 'Country code is false.';
row.commit();
}
}
if(rowNumber == lastRow.number){
console.log('Export file location is ' + exportLocation)
console.log('All Done.')
document.getElementById("btn1").disabled = false;
}
});
return workbook.xlsx.writeFile(exportLocation+ "\\export.xlsx");
});
}