npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

excel-to-mongodb

v2.6.1

Published

A node module to covert a spreadsheet of Excel to a collection in MongoDB.

Readme

excel-to-mongoDB

Build Status CircleCI

This module converts your correctly formatted Excel spreadsheet to a collection in specified database in MongoDB.

Excel Formats Supported

Supported Excel formats are XLS/XLSX/CSV

Spreadsheet Format

Please have a look at the sample Excel sheets provided to have a clear view of the File. Microsoft Sample Sheet

Installation

npm install excel-to-mongoDB --save

Testing

git clone https://github.com/ngudbhav/excel-to-mongoDB.git
cd excel-to-mongoDB/

Navigate to the folder.

cd test/
nano test.js

Now this file needs the MongoDB credentials. Provide those credentials in String format and save by pressing the following keys.

'CTRL+X'
'Y'
'Return'

Get back and test the module.

cd ..
npm test

Using

Note: Please correctly format the Excel sheet else this won't work.

var excelMongo = require('excel-to-mongoDB');

This module needs 3 arguments. The first one is the object with your credentials.

var credentials = {
	host: host,
	path: path for the excel file,
	collection: Collection name for creation,
	db: Your Database name,
	user: username for authentication. Leave blank if no authentication required,
	pass: password for authentication.
	connection: Connection Object from mongodb client. Leave blank to create a connection,
	endConnection*: 
};
  • Please note that endConnection false may not terminate the process.

The second one is an optional argument of options with default values as follows.

var options = {
	safeMode: false //Backup the db to the current working directory in dump/<db> folder.
	verbose: false //Console.log the current step processing.
	customStartEnd: false //Custom insert the row and columns rather than full excel-file. Do take care! Specifying endRow or endCol may result in insertion of redundant data.
	startRow: <required> //Valid only if customStartEnd is true. Defines the start Row of the data.
	endRow: <required> //Valid only if customStartEnd is true. Defines the end Row of the data.
	startCol: <required> //Valid only if customStartEnd is true. Defines the start Column of the data.
	endCol: <required> //Valid only if customStartEnd is true. Defines the end Column of the data.
	destination: '' // Valid only if safeMoode is true. Defines the destination of the dump file of db
}

The third argument is the callback function which should be executed.

try {
  excelMongo.covertToMongo(credentials, options, callback); //returns documents inserted in the database.
} catch(error) {
  throw error;
}

try/catch is always recommended because of the type of errors that can occur.

Error in safeMode option

Windows users need to add the following path to the environment path variable.
C:\Program Files\MongoDB\Server\<version>\bin

Right click 'This PC', head to 'properties' and 'Advanced System Settings'. From there, Click on 'Environment Variables'. Under System Variables, Search for 'PATH'. Double click the entry, click on new and add the above path.
Restart your console and you should be good to go.

Linux/Unix Users please check your installation or .bashrc.

Want to covert to MYSQL instead?

We have got you covered! GitHub Link.

Want to use the GUI instead?

We have got you covered! GitHub Link.