master
WalterBright 4 years ago
parent c53d5c0650
commit 6699ede0fa
  1. 10
      README.md
  2. 23
      exportJsonLines.js
  3. 11
      package.json
  4. BIN
      国服小助手.xlsx
  5. BIN
      国际服小助手.xlsx
  6. BIN
      生涯地图.xlsx

@ -1,7 +1,5 @@
# XLSX-TOOL
# 狂野飙车9数据表
运行命令
```cmd
node exportJson 文件名 表名
```
+ 国服全车数据表
+ 国际全车服数据表
+ 生涯地图表

@ -2,23 +2,22 @@ const xlsx=require('xlsx')
const fs = require('fs')
const handle = {
topSpeed:value=>Number(Number(value).toFixed(1)),
acceleration:value=>Number(Number(value).toFixed(2)),
handling:value=>Number(Number(value).toFixed(2)),
nitro:value=>Number(Number(value).toFixed(2)),
nitroDuration:value=>Number(Number(value).toFixed(2)),
car_id:value=>''+value
topSpeed: (value) => Number(Number(value).toFixed(1)),
acceleration: (value) => Number(Number(value).toFixed(2)),
handling: (value) => Number(Number(value).toFixed(2)),
nitro: (value) => Number(Number(value).toFixed(2)),
nitroDuration: (value) => Number(Number(value).toFixed(2)),
car_id: (value) => '' + value,
}
const copy=obj=>JSON.parse(JSON.stringify(obj))
const copy = (obj) => JSON.parse(JSON.stringify(obj))
const useHandle = (obj, handle) => {
let res = copy(obj)
Object.keys(handle).forEach(key=>{
Object.keys(handle).forEach((key) => {
if (res[key]) {
res[key] = handle[key](res[key])
}
})
return res
}
@ -29,8 +28,9 @@ const exportJsonLines=(xlsxFilePath,sheetName)=>{
const dataJson = xlsx.utils.sheet_to_json(table.Sheets[sheetName])
// console.log(table.Sheets[sheetName]["!merges"])
const dataLines = dataJson
.map(obj=>useHandle(obj,handle))
.map(dataItem=>JSON.stringify(dataItem)).join('\n')
.map((obj) => useHandle(obj, handle))
.map((dataItem) => JSON.stringify(dataItem))
.join('\n')
const dataBuffer = Buffer.from(dataLines)
fs.writeFileSync(dataPath, dataBuffer)
@ -43,7 +43,6 @@ const exportJsonLines=(xlsxFilePath,sheetName)=>{
const [, , xlsxFilePath, sheetName] = process.argv
try {
if (xlsxFilePath && sheetName) {
exportJsonLines(xlsxFilePath, sheetName)
console.log('执行成功')

@ -6,14 +6,15 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gl:carList":"node .\\exportJsonLines.js .\\国际服小助手.xlsx 数据卡片",
"gl:versionNoteGL":"node .\\exportJsonLines.js .\\国际服小助手.xlsx versionNoteGL",
"gl:careerSeasonGL":"node .\\exportJsonLines.js .\\生涯地图.xlsx careerSeasonGL",
"gl:versionNote":"node .\\exportJsonLines.js .\\国际服小助手.xlsx versionNoteGL",
"gl:careerSeason":"node .\\exportJsonLines.js .\\生涯地图.xlsx careerSeasonGL",
"al:carList":"node .\\exportJsonLines.js .\\国服小助手.xlsx 数据卡片",
"al:versionNoteAL":"node .\\exportJsonLines.js .\\国服小助手.xlsx versionNoteAL",
"al:careerSeasonAL":"node .\\exportJsonLines.js .\\生涯地图.xlsx careerSeasonAL",
"al:versionNote":"node .\\exportJsonLines.js .\\国服小助手.xlsx versionNoteAL",
"al:careerSeason":"node .\\exportJsonLines.js .\\生涯地图.xlsx careerSeasonAL",
"tracks":"node .\\exportJsonLines.js .\\生涯地图精简.xlsx track"
"tracks":"node .\\exportJsonLines.js .\\生涯地图.xlsx track",
"mapTheme":"node .\\exportJsonLines.js .\\生涯地图.xlsx mapTheme"
},
"author": "",
"license": "ISC",

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save