game2006web3new/server/web3tools/import_contribution.js
aozhiwei 167cfa8c85 1
2024-07-24 13:48:02 +08:00

24 lines
871 B
JavaScript

const exceljs = require('exceljs');
async function main() {
const workbook = new exceljs.Workbook();
const dataBook = await workbook.xlsx.readFile('/home/kingsome/contribution072301.xlsx');
const nowTime = Math.floor((new Date()).getTime() / 1000);
dataBook.eachSheet((sheet, sheetIndex) =>{
//console.log(sheet.name, sheetIndex);
if (sheet.name == '贡献点') {
sheet.eachRow((row, index) => {
const accountAddress = row.getCell(3).value.toLowerCase();
const value = row.getCell(4).value.result;
if (accountAddress.length >= 30) {
const insertSql = 'INSERT INTO t_contribution(account_address, contribution, createtime, modifytime) ' +
"VALUES('" + accountAddress + "'," + value + ',' + nowTime + ',' + nowTime + ");";
console.log(insertSql);
}
});
}
});
}
main();