[問題] node.js迴圈讀取檔案問題
hi 各位大大好
小魯想用node.js弄個for迴圈幫我讀取xlsx檔(用node-xlsx套件)
但是遇到一點小問題 就是file_path 總是拿到迴圈的最後一個數字
例如: i=100
不知道該如何修正我的程式才能正確的讀取每一個檔案?
for(var i=1; i<=100;i++){
file_path = i+'.xlsx'; // 檔名
check_file(file_path, function(back){ //確認檔案存在
console.log(file_path);
if( back.status == 1){
load_xlsx(back.path, function(data){
// 檔案存在 讀取xlsx
report[data[0]] = data[1];
count++;
if(count > 100){
console.log(report);
}
});
}
});
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.87.162.162
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1463464158.A.591.html
※ 編輯: jikker (219.87.162.162), 05/17/2016 13:49:47
→
05/17 14:57, , 1F
05/17 14:57, 1F
推
05/18 00:34, , 2F
05/18 00:34, 2F
→
05/18 00:38, , 3F
05/18 00:38, 3F
→
05/18 10:22, , 4F
05/18 10:22, 4F
→
05/18 10:22, , 5F
05/18 10:22, 5F
→
05/18 13:04, , 6F
05/18 13:04, 6F
推
05/18 13:15, , 7F
05/18 13:15, 7F
→
05/19 00:45, , 8F
05/19 00:45, 8F
→
05/19 00:45, , 9F
05/19 00:45, 9F
推
05/19 02:08, , 10F
05/19 02:08, 10F
→
05/19 07:25, , 11F
05/19 07:25, 11F
推
05/19 10:45, , 12F
05/19 10:45, 12F
→
05/19 10:45, , 13F
05/19 10:45, 13F
→
05/19 10:46, , 14F
05/19 10:46, 14F
→
05/29 20:52, , 15F
05/29 20:52, 15F
→
05/29 20:52, , 16F
05/29 20:52, 16F
→
05/29 20:53, , 17F
05/29 20:53, 17F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章