Node.js Import Excel File to MongoDB – using Convert-Excel-To-Json lib

Tags: node, mongodb, excel, restapi
Published: 2021-05-16 10:17:45

https://grokonez.com/node-js/node-js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib

Node.js Import Excel File to MongoDB – using Convert-Excel-To-Json lib


<p>In the tutorial, Grokonez shows how to import data from Excel File to MongoDB with Node.js using <code>Convert-Excel-To-Json</code> lib.</p>



<p>Related posts:
- <a href="https://grokonez.com/node-js/nodejs-express-restapi-upload-import-excel-file-data-to-mongodb-using-convert-excel-to-json-multer">Nodejs Express RestAPI – Upload/Import Excel file/data to MongoDB – using Convert-Excel-to-Json + Multer</a>
</p>

<!--more-->

<h2>Technologies</h2>

<ul><li>Node.js</li><li>MongoDB</li><li>Convert-Excel-To-Json</li></ul>

<h2>Goal</h2>

<p>– We create a Node.js project as below structure:</p>

<figure class="wp-block-image"><img src="https://grokonez.com/wp-content/uploads/2019/03/node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-project-structure-1.png" alt="node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-project-structure-1" class="wp-image-17162"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>– Excel File:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17163} -->
<figure class="wp-block-image"><img src="https://grokonez.com/wp-content/uploads/2019/03/node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-excel-file-1.png" alt="node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-excel-file-1" class="wp-image-17163"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>-&gt; Results:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17164} -->
<figure class="wp-block-image"><img src="https://grokonez.com/wp-content/uploads/2019/03/node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-mongodb-documents-1.png" alt="node.js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib-mongodb-documents" class="wp-image-17164"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h2>Practice</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":5} -->
<h3>Install MongoDB &amp; Convert-Excel-To-Json</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Init <code>package.json</code> file by cmd: <code>npm init</code> -&gt; Then install <code>mongodb</code> &amp; <code>convert-excel-to-json</code> libs:</p>
<!-- /wp:paragraph -->

<!-- wp:preformatted -->
<pre><code class="language-javascript">$npm install mongodb
$npm install convert-excel-to-json
</code></pre>
<!-- /wp:preformatted -->

<!-- wp:paragraph -->
<p>-&gt; <code>package.json</code> file:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre><code class="language-javascript">{
  "name": "node.js-import-excel-file-to-mongodb",
  "version": "1.0.0",
  "description": "Node.js Import Excel File to MongoDB with Convert-Excel-To-Json lib",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
	"start": "node index.js"
  },
  "keywords": [
    "Node.js",
    "Excel",
    "MongoDB",
    "Convert-Excel-To-JSON"
  ],
  "author": "grokonez.com",
  "license": "ISC",
  "dependencies": {
    "convert-excel-to-json": "^1.6.1",
    "mongodb": "^3.1.13"
  }
}
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":5} -->
<h3>Import Excel File to MongoDB</h3>

More at:

https://grokonez.com/node-js/node-js-import-excel-file-to-mongodb-using-convert-excel-to-json-lib

Node.js Import Excel File to MongoDB – using Convert-Excel-To-Json lib