-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (22 loc) · 812 Bytes
/
index.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
const json = require('./result2.json');
const exceljs = require('exceljs');
const columnConfig = require('./columnconfig.json');
const workbook = new exceljs.Workbook();
workbook.xlsx.readFile('Mobiles.xlsx').then(wb => {
const worksheet = wb.getWorksheet('Sheet1')
let rowNumber = 2;
for (const row of json.values()) {
let columnNumber = 1;
const excelRow = worksheet.getRow(rowNumber);
for (const column of columnConfig.values()) {
if (column === 'MediaLinks')
excelRow.getCell(columnNumber).value = row[column].join(', ')
else
excelRow.getCell(columnNumber).value = row[column];
columnNumber++;
}
excelRow.commit();
rowNumber++;
}
wb.xlsx.writeFile('Mobiles.xlsx')
});