| 2 | const fs = require('fs'); |
| 3 | |
| 4 | async function main(){ |
| 5 | const workbook = new Workbook(); |
| 6 | |
| 7 | const workbook2 = await workbook.xlsx.readFile('./bundle.xlsx'); |
| 8 | |
| 9 | const zhCNBundle = {}; |
| 10 | const enUSBundle = {}; |
| 11 | |
| 12 | workbook2.eachSheet((sheet) => { |
| 13 | |
| 14 | sheet.eachRow((row, index) => { |
| 15 | if(index === 1) { |
| 16 | return; |
| 17 | } |
| 18 | const key = row.getCell(1).value; |
| 19 | const zhCNValue = row.getCell(4).value; |
| 20 | const enUSValue = row.getCell(5).value; |
| 21 | |
| 22 | zhCNBundle[key] = zhCNValue; |
| 23 | enUSBundle[key] = enUSValue; |
| 24 | }) |
| 25 | }); |
| 26 | |
| 27 | console.log(zhCNBundle); |
| 28 | console.log(enUSBundle); |
| 29 | fs.writeFileSync('zh-CN.json', JSON.stringify(zhCNBundle, null, 2)); |
| 30 | fs.writeFileSync('en-US.json', JSON.stringify(enUSBundle, null, 2)); |
| 31 | } |
| 32 | |
| 33 | main(); |