Hướng Dẫn Convert Dữ Liệu Từ File Excel Sang JSON Cho App Pugo
Có thể bạn quan tâm
Skip to content Search Gists Search Gists All gists Back to GitHub Sign in Sign up Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }}
lephuhai/README.md Last active March 26, 2017 05:49 Show Gist options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.
Instantly share code, notes, and snippets.
- Download ZIP
- Star (0) You must be signed in to star a gist
- Fork (0) You must be signed in to fork a gist
- Embed Select an option
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/lephuhai/95e62d82fe70e57dc60622421375ca4d.js"></script> - Save lephuhai/95e62d82fe70e57dc60622421375ca4d to your computer and use it in GitHub Desktop.
- Embed Embed this gist in your website.
- Share Copy sharable link for this gist.
- Clone via HTTPS Clone using the web URL.
No results found
Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/lephuhai/95e62d82fe70e57dc60622421375ca4d.js"></script> Save lephuhai/95e62d82fe70e57dc60622421375ca4d to your computer and use it in GitHub Desktop. Download ZIP Hướng dẫn convert dữ liệu từ file Excel sang JSON cho app Pugo Raw README.md-
Bước 1: Cài đặt Nodejs
-
Bước 2: Cài đặt các node modules sử dụng npm
- Bước 3: Sử dụng nodejs để chạy file script.js
hoặc
npm startRaw script.js This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden charactersChú ý: Mỗi lần thực hiện convert data thì phải xóa các file json đã có trong thư mục result. Script sẽ đọc dữ liệu từ file pugo.xlsx và tên sheet của file excel là Sheet1
| "use strict" |
| let xlsx = require('xlsx'), |
| _ = require('lodash'), |
| workbook = xlsx.readFile('./pugo.xlsx'), |
| data = workbook.Sheets.Sheet1, |
| fs = require('fs') |
| const directory = 'result' |
| let result = {}; |
| for (let k in data) { |
| if (data.hasOwnProperty(k)) { |
| if (k[0] === '!') continue; |
| if (!_.isArray(result[k.slice(1)])) result[k.slice(1)] = []; |
| result[k.slice(1)].push(data[k].v); |
| } |
| } |
| const keys = Object.keys(result) |
| for (let i = 1; i < keys.length; i++) { |
| if (result[i][0] !== 'STT') { |
| fs.appendFileSync(`./${directory}/${result[i][1]}.json`,` |
| { |
| "Time" : ${result[i][8]}, |
| "Question" : "${result[i][2]}", |
| "A" : "${result[i][3]}", |
| "B" : "${result[i][4]}", |
| "C" : "${result[i][5]}", |
| "D" : "${result[i][6]}", |
| "Answer" : "${result[i][7]}" |
| },`) |
| } |
| } |
| fs.readdir(`./${directory}`, function (err, files) { |
| files.forEach(function (file) { |
| let x = fs.readFileSync(`./${directory}/${file}`, 'utf8') |
| fs.writeFileSync(`./${directory}/${file}`, `[${x.substring(0, x.length -1).trim()}]`, {mode: 0x1b6}) |
| }) |
| }) |
| console.log("[*] Create JSON files successfully!!") |
Từ khóa » Chuyển Excel Sang Json
-
Công Cụ Chuyển đổi EXCEL Sang JSON - Aspose Products
-
Chuyển đổi EXCEL Sang JSON Trực Tuyến Miễn Phí - AnyConv
-
Chuyển đổi XLSX (Excel) Sang JSON
-
Chuyển đổi Excel Sang JSON
-
Công Cụ Chuyển đổi Excel Sang JSON Trực Tuyến Miễn Phí - Bfotool
-
Chuyển đổi EXCEL Sang JSON Qua C - Aspose
-
Cách Chuyển Excel Sang JSON đơn Giản Nhất
-
4 Bước Dễ Dàng để Xuất Tệp Excel Sang JSON Bằng C
-
Cách Chuyển đổi XLSX (Excel) Sang JSON - Morioh
-
Chuyển đổi XLS Sang JSON Trực Tuyến | Ứng Dụng GroupDocs Phí
-
Cách Chuyển đổi File Json Sang Excel Chi Tiết Bằng Power Query
-
Excel To Json Converter
-
Phần Mềm - CHUYỂN ĐỔI JSON SANG EXCEL
-
Cách Chuyển đổi Tệp JSON Sang Microsoft Excel