https://atmospherejs.com/huaming/js-xlsx is really good, i copy pasted some code and viola or do preprocessor to convert xls to csv and with papaparse upload it with method
Hey Muphet, Thanks for your response!
My issue is that XLSX.readFile is not being recognised by meteor. There seems to be some issue in loading packages. Tried npm install xlsx - even that does not work.
I tried XLSX=npm.require(‘xlsx’) and many more such combos but in vain.
What I need is simple extraction of data from the excel file.
I want to access the data inside and upload excel file. I am writing below code in server side but getting error like Exception while invoking method ‘filehere’ undefined
Meteor.methods({
filehere(){
var fs = Npm.require('fs');
var path = Npm.require('path');
var basepath = path.resolve('.').split('.meteor')[0];
console.log(basepath);
var excel = new Excel('xls');
var workbook = excel.readFile(basepath+'server/MeteorJs.xls');
//var youSheetName = workbook.sheetNames;
/*workbook = XLSX.readFile(inputname);
var sheetNames = workbook.sheetNames;
*/
}
wrote the code on server side main.js but unable to access the workbook yet.
The console displays “Undefined” when console.log(yourSheetsName); is run.
I used exceljs package for this.
extract(filename){
console.log(“In Server!!”);
console.log(filename);
var fs = Npm.require(‘fs’);
var path = Npm.require(‘path’);
var basepath = path.resolve(’.’).split(’.meteor’)[0];
basepath = basepath + ‘server/5+2–Network-05-05-16.xls’;
console.log(basepath);
var Excel = require('exceljs');
var workbook = new Excel.Workbook();
workbook.xlsx.readFile(basepath);
var yourSheetsName = workbook.SheetNames;
console.log(yourSheetsName);
}