0

i am facing an issue where i need to get data from an xl file and convert the record or row to a json format and send it to a server so the issue here is the file gets changed frequently(mean new data will be added data will be appended to new rows) so for every change we need to send the added data to server i have come up with a logic to make a note of last row i have send to server and when there is change from previous variable that stores last row sent i will send rows from that variable to last row .

so i want to know is there a way to just make a refernce to a xlsx file rather than loading the whole file and getting row by row data

mycode it doesnt work that way:

var fs = require('fs');
var XLS= require('xlsx');

var book = XLS.readFile('test.xlsx');

var sheet_name_list = book.SheetNames[0];
var Sheet1 = book.Sheets[sheet_name_list];
//console.log(Sheet1);


var j = XLS.utils.sheet_to_json(Sheet1['A17']);
console.log(j);
Rohit Rock
  • 9
  • 1
  • 7

1 Answers1

0

What you want is observe file changes, node.js has [fs.watch][1] method for this

Observe file changes with node.js

you need reread file every time that you get change event.

Also you can try to use excel-js package and reading xlsx via Stream, but I'm not sure is it send you updates while you adding rows

Community
  • 1
  • 1
vmkcom
  • 1,630
  • 11
  • 17