node 讀取 xlsx檔案寫入檔案

2021-09-30 19:05:24 字數 1102 閱讀 9757

node讀取.xlsx檔案

var fs =

require

('fs');

var events =

require

('events');

//引入node,解析.xlsx檔案的模組

var xlsx =

require

('node-xlsx');

var eventemitter =

newevents.eventemitter()

;var work;

var workdata;

var objcategory=

;var arycategory=

;// 建立事件處理程式

varconnecthandler

=function

connected()

; list.japanexitchinese = workdata[i][0

];list.japanexitjapanese = workdata[i][1

];list.japanexitenglish = workdata[i][2

];arycategory.

push

(list)

}// 觸發 data_received 事件

eventemitter.

emit

('data_received');

}// 繫結 connection 事件處理程式

eventemitter.on(

'connection'

, connecthandler)

;// 使用匿名函式繫結 data_received 事件

eventemitter.on(

'data_received'

,function()

);})

;// 觸發 connection 事件

eventemitter.

emit

('connection');

console.

log(

"程式執行完畢。"

);

Node學習筆記(六) 檔案讀取 寫入 刪除

檔案讀取 匯入檔案模組 匯入檔案模組,node自帶的模組 let fs require fs 同步讀取 node預設是非同步 同步讀取檔案,會阻塞和等等 let content fs.readfilesync fs 01.txt console.log content 01txt中的內容是01txt...

node檔案流的讀取與寫入

1 檔案流寫入 const fs require fs const ws fs.createwritestream test.txt for let i 0 i 10000 i err ws.end 標記檔案寫入完成 ws.on open ws.on ready ws.on close ws.on ...

python讀取xlsx檔案

我是在win7下讀取的。python版本是 3.5 import xlrd import re import sqlite3 def read xlsx workbook xlrd.open workbook e 20160322.xlsx booksheet workbook.sheet by n...