master
WalterBright 4 years ago
commit 10bb37eb33
  1. 3
      .gitignore
  2. 7
      README.md
  3. 0
      dist/.gitkeep
  4. 53
      exportJsonLines.js
  5. 23
      package.json
  6. 88
      yarn.lock
  7. BIN
      国服小助手.xlsx
  8. BIN
      国际服小助手.xlsx
  9. BIN
      生涯地图精简.xlsx

3
.gitignore vendored

@ -0,0 +1,3 @@
dist/*.json
node_modules/

@ -0,0 +1,7 @@
# XLSX-TOOL
运行命令
```cmd
node exportJson 文件名 表名
```

@ -0,0 +1,53 @@
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
}
const copy=obj=>JSON.parse(JSON.stringify(obj))
const useHandle=(obj,handle)=>{
let res=copy(obj)
Object.keys(handle).forEach(key=>{
if(res[key]){
res[key]=handle[key](res[key])
}
})
return res
}
const exportJsonLines=(xlsxFilePath,sheetName)=>{
const table=xlsx.readFile(xlsxFilePath)
const dataPath=`dist\\${xlsxFilePath}.${sheetName}.line.json`
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')
const dataBuffer=Buffer.from(dataLines)
fs.writeFileSync(dataPath,dataBuffer)
}
//运行命令 node exportJsonLines 文件名 表名,即可导出文件
// node ./exportJsonLines.js ./狂野飙车9生涯数据-地图.xlsx forJson
const [,,xlsxFilePath,sheetName]=process.argv
try{
if(xlsxFilePath&&sheetName){
exportJsonLines(xlsxFilePath,sheetName)
console.log('执行成功')
}
}catch(e){
console.log(e)
}

@ -0,0 +1,23 @@
{
"name": "a9-data",
"version": "1.0.0",
"description": "",
"main": "index.js",
"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",
"al:carList":"node .\\exportJsonLines.js .\\国服小助手.xlsx 数据卡片",
"al:versionNoteAL":"node .\\exportJsonLines.js .\\国服小助手.xlsx versionNoteAL",
"al:careerSeasonAL":"node .\\exportJsonLines.js .\\生涯地图精简.xlsx careerSeasonAL",
"tracks":"node .\\exportJsonLines.js .\\生涯地图精简.xlsx track"
},
"author": "",
"license": "ISC",
"dependencies": {
"xlsx": "^0.15.4"
}
}

@ -0,0 +1,88 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
adler-32@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.2.0.tgz#6a3e6bf0a63900ba15652808cb15c6813d1a5f25"
integrity sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==
dependencies:
exit-on-epipe "~1.0.1"
printj "~1.1.0"
adler-32@~1.3.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.3.1.tgz#1dbf0b36dda0012189a32b3679061932df1821e2"
integrity sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==
cfb@^1.1.4:
version "1.2.2"
resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.2.2.tgz#94e687628c700e5155436dac05f74e08df23bc44"
integrity sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==
dependencies:
adler-32 "~1.3.0"
crc-32 "~1.2.0"
codepage@~1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/codepage/-/codepage-1.14.0.tgz#8cbe25481323559d7d307571b0fff91e7a1d2f99"
integrity sha512-iz3zJLhlrg37/gYRWgEPkaFTtzmnEv1h+r7NgZum2lFElYQPi0/5bnmuDfODHxfp0INEfnRqyfyeIJDbb7ahRw==
dependencies:
commander "~2.14.1"
exit-on-epipe "~1.0.1"
commander@~2.14.1:
version "2.14.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa"
integrity sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==
commander@~2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==
crc-32@~1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"
integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==
exit-on-epipe@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz#0bdd92e87d5285d267daa8171d0eb06159689692"
integrity sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==
frac@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/frac/-/frac-1.1.2.tgz#3d74f7f6478c88a1b5020306d747dc6313c74d0b"
integrity sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==
printj@~1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222"
integrity sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==
ssf@~0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/ssf/-/ssf-0.10.3.tgz#8eae1fc29c90a552e7921208f81892d6f77acb2b"
integrity sha512-pRuUdW0WwyB2doSqqjWyzwCD6PkfxpHAHdZp39K3dp/Hq7f+xfMwNAWIi16DyrRg4gg9c/RvLYkJTSawTPTm1w==
dependencies:
frac "~1.1.2"
wmf@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wmf/-/wmf-1.0.2.tgz#7d19d621071a08c2bdc6b7e688a9c435298cc2da"
integrity sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==
xlsx@^0.15.4:
version "0.15.6"
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.15.6.tgz#461f841d6d9ea1a8375e2cd246bf23aece08a1d5"
integrity sha512-7vD9eutyLs65iDjNFimVN+gk/oDkfkCgpQUjdE82QgzJCrBHC4bGPH7fzKVyy0UPp3gyFVQTQEFJaWaAvZCShQ==
dependencies:
adler-32 "~1.2.0"
cfb "^1.1.4"
codepage "~1.14.0"
commander "~2.17.1"
crc-32 "~1.2.0"
exit-on-epipe "~1.0.1"
ssf "~0.10.3"
wmf "~1.0.1"

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save