The file format

The fs module nod-xlsx module and line-reader module are used.

var fs = require('fs');
var xlsx = require('node-xlsx');
var lineReader = require('line-reader');
 
 
 
 
var bigArr=[];
 
 
lineReader.eachLine('1.txt'.function(line, last) {
  var row=line.split("-");
  bigArr.push(row);
  if (last) {
  	console.log(bigArr);
  	var buffer = xlsx.build([
	    {
	        name:'sheet1'.data:bigArr
	    }        
	]);
 
 
	// Insert the contents of the file into the new file
	fs.writeFileSync('1.xlsx',buffer,{'flag':'w'});
  	return false}});Copy the code