cotalkerpartners / mongo-xlsx Goto Github PK
View Code? Open in Web Editor NEWConvert Mongo data into Excel and vice versa @ Node.js. MongoDB Mongoose Dump to excel.
License: MIT License
Convert Mongo data into Excel and vice versa @ Node.js. MongoDB Mongoose Dump to excel.
License: MIT License
Exp:
{id: 100}
expected show in xlsx:
{identity: 100}
Export excel file download issue while download excel file from return path.
There is very small error in quick example in *README.md
*
/* Read Excel */
mongoxlsx.xlsx2MongoData("./file.xlsx", model, function(err, mongoData) {
console.log('Mongo data:', mongoData);
});
"mongoxlsx should be mongoXlsx"
Although it works for some xlsx files, for other ones I get this error:
/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:398
mongoModel.forEach(function(f) {
^
TypeError: mongoModel.forEach is not a function
at convertMongoModelToObject (/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:398:14)
at Object.exports.xlsxData2MongoData (/Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:328:24)
at /Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/mongo-xlsx.js:305:29
at /Volumes/Data/Projects security/nxte/big-data/database/node_modules/mongo-xlsx/lib/xlsx-rw.js:69:12
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Hi
I am using mongo-xlsx module to convert excel sheet to mongo data but i am getting empty cells also. Can you please update this module to get only non-empty cells data.
thanks
Can someone give a snippet on how to add styles ?
Morning!
I can't seem to get mongo-xlsx to autogenerate the model. My spreadsheet has a lot of columns that might change so I don't really want to manually create the model myself.
var mongoXlsx = require('mongo-xlsx');
var mongoModel;
mongoXlsx.xlsx2MongoData("avivadotcom.xlsx",mongoModel, function (err, mongoData) {
console.log('Mongo data:', mongoData);
});
without declaring mongoModel - I get "mongoModel is undefined". If i declare it as null then I get "Cannot read property 'split' of undefined from line 356 (mongo-xlsx.js).
Any pointers?
Cheers!
i have to Change save xlsx file in another folder.
I try to assign save flag to false but unsuccess, I have investigated and found that below code make stuck
if (!options.save) {options.save = makeDefault('save');}
option.save always set to true.
Please take time to fix this bug.
Thanks
Is this still being developed or is it another dead project?
Using below code, not able to convert the data into one excel with mutiple sheets. I am getting all data in one sheet.
var jsonXlsx = [[{ "Name": "Eddie", "Email": "edward@mail" }], [{ "Name": "Nico", "Email": "nicolas@mail" }]] ;
const sheets = ['a','b'];
var excelPageData = [];
/* Generate automatic model for processing (A static model should be used) */
var model = mongoXlsx.buildDynamicModel(jsonXlsx);
/* Generate Excel */
excelPageData.push(mongoXlsx.mongoData2XlsxData(jsonXlsx, model));
mongoXlsx.mongoData2XlsxMultiPage(excelPageData, sheets, function(err, data) {
console.log(err)
console.log('File saved at:', data.fullPath);
});
The program works fine if model name passed as null. however, when I run it using mapping model it always lead to below error. Please help!
TypeError: mongoModel.forEach is not a function
at convertMongoModelToObject (D:\react\react-redux\metrics-node-services\node_modules\mongo-xlsx\lib\mongo-xlsx.js:398:14)
at Object.exports.xlsxData2MongoData (D:\react\react-redux\metrics-node-services\node_modules\mongo-xlsx\lib\mongo-xlsx.js:328:24)
at D:\react\react-redux\metrics-node-services\node_modules\mongo-xlsx\lib\mongo-xlsx.js:294:26
at D:\react\react-redux\metrics-node-services\node_modules\mongo-xlsx\lib\xlsx-rw.js:69:12
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
model-config.txt
sample-output-withNull.txt
var ms = ((numericExcelDate - (25567 - 1)) * 86400 * 1000);
var ms_offset = (new Date().getTimezoneOffset() * 60000);
var dt = new Date(ms + ms_offset);
anArray[0] | anArray[1] | anArray[2] | aString[0] |
---|---|---|---|
1 | a | 3 | hey |
it could be, optionally, converted to:
anArray[0] | aString[0] |
---|---|
1, a, 3 | hey |
Allowing external systems/scripts to easily access information based on column position
I am convering .xlsx file of around 4 lakh record into json array using this package method but it is converting only 65535 records
Is their any component available to check whether more than one sheets available in existing excel while importing as a JSON for operation??
My exported data is not comming in order,its coming a single character in a column
data.collection("Points”).find({'businessId': ‘shopname’ ,’_created_at':{$gt:d}}, { _id: false}).toArray(function(err, result) {
for(f=0;f<result.length;f++)
{
data = '{'+" Shop : ""+result[f].businessname+"", Points : "+result[f].point+'}';
data = data+" , " +data;
}
//data export
data = [data];
data = data.replace(/'/g, '');
var model = mongoXlsx.buildDynamicModel(data);
mongoXlsx.mongoData2Xlsx(data, model, function(err, data) {
console.log('File saved at:', data.fullPath);
});
This is what i am doing
but i guess my data comes as
['{shop : "shopname",Points : 10 }'];
Please help .i tried replace function but its not working .
Or is it any other issue,
iam trying this to generate multiple sheets in one excel,but iam getting output as object
const sheets = ['a','b'];
mongoData2XlsxMultiPage(monogData, sheets, options, callback)
When i am adding timestamps (createdAt and updatedAt) for converting mongo to xl data , I am getting this error "Cannot read property 'SSF' of undefined". That error is coming only when I am adding timestamps. Can someone please help me out ?
timestamps in mongo db :
"updatedAt" : ISODate("2016-11-24T05:50:28.240Z")
"createdAt" : ISODate("2016-11-22T16:23:46.127Z")
Is there a way to declare in "options" the file name to be exported ?
I am converting excel data to get data in json form. An issue I am facing is that whenever I am passing the date in between 01-09 , the date is converted into some number.
examplex.xlsx
This is the excel data
For the last two row data is correct.But in the 1st row the bike purchasing date is some random number.
Its not converting the date properly.
This is the data which it is converting
data [ { Name: 'Suresh',
Address: 'mumbai',
'Purchase date': 42800,
'Bike Dealership Name': 'sales',
'Bike Make': 'hero',
'Bike Model': 'splender' },
{ Name: 'Yash',
Address: 'bhopal',
'Purchase date': '15-05-2017',
'Bike Dealership Name': 'gv',
'Bike Make': 'HONDA',
'Bike Model': 'aviator' },
{ Name: 'Saif',
Address: 'Bhopal',
'Purchase date': '31-05-2017',
'Bike Dealership Name': 'vaibhav',
'Bike Make': 'Honda',
'Bike Model': 'Dio' } ]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.