# Import excel file and read data from it

**URL:** <https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [19 June 2023 14:11 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302 "2023-06-19T14:11:54Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![douchebagraccoon](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@douchebagraccoon](https://discourse.nodered.org/u/douchebagraccoon)\
**Post date:** [19 June 2023 14:11 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/1 "2023-06-19T14:11:54Z")

</div>

Hello everyone,

Is it possible to import an excel file (xlsx, xlsm) into node-red and extract data from it without precising the path of said file ?

Almost like a "drag and drop your file here" on the dashboard.

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 June 2023 23:37 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/2 "2023-06-20T23:37:51Z")

</div>

There are nodes you can use, you could also use the readExcelFile npm library directly in a function node if you prefer.

---

<div class="post-metadata">

**Author:** ![douchebagraccoon](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@douchebagraccoon](https://discourse.nodered.org/u/douchebagraccoon)\
**Post date:** [21 June 2023 06:52 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/3 "2023-06-21T06:52:46Z")

</div>

Thank you for your answer ! But I'm pretty new to node red and I don't know how to use an npm library in a function node, do you perhaps have an example ? (Sorry !)

Also, can it be done with no access to the internet ?

Thanks in advance !

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 June 2023 07:48 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/4 "2023-06-21T07:48:44Z")

</div>

see [this article](https://flowforge.com/blog/2023/06/import-modules/) for using npm modules in a function node

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 June 2023 18:56 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/5 "2023-06-21T18:56:07Z")

</div>

Start by looking through the "flows" section of this site and search for excel to see if you can find a suitable node. The use of an npm library is a bit more of an advanced topic and probably not so useful if you don't know any JavaScript.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [22 June 2023 01:45 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/6 "2023-06-22T01:45:45Z")

</div>

I could be wrong but I haven't seen any nodes that support drag and drop on Dashboard.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [22 June 2023 06:00 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/7 "2023-06-22T06:00:00Z")

</div>

The [spreadsheet-in node](https://flows.nodered.org/node/node-red-contrib-spreadsheet-in) can read excel files, works quite well. This could be used with a file upload in dashboard, or any other way you read a file within node-red

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 June 2023 06:21 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/8 "2023-06-22T06:21:30Z")

</div>

There is an example flow using dropzone js here: [https://flows.nodered.org/flow/c70d0b4c54b583cf30c7e989b74feb68](https://flows.nodered.org/flow/c70d0b4c54b583cf30c7e989b74feb68)

---

<div class="post-metadata">

**Author:** ![douchebagraccoon](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@douchebagraccoon](https://discourse.nodered.org/u/douchebagraccoon)\
**Post date:** [22 June 2023 06:47 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/9 "2023-06-22T06:47:15Z")

</div>

Thank you for your reply ; I did try to use the spreadsheet-in nodes, however I can't get them to work...

The first time I deploy the flow, nothing happens and the debug nodes return nothing, and if I try to change the settings of the nodes (for instance, the output and encoding of the "read file" node, or the range of cells in the "sheet to json" node) : whenever I try to deploy, it says "lost connection to the server" and basically crashes...

Did I set up the nodes wrong ?

Sorry and thank you for your help !

Node-RED version : v3.0.2  
Node.js version : v18.15.0

```auto
[
    {
        "id": "8c0b80d407f06452",
        "type": "book",
        "z": "2d72e3a85743de48",
        "name": "test.xlsm",
        "raw": false,
        "x": 720,
        "y": 220,
        "wires": [
            [
                "a95ed85a5a8d87ae"
            ]
        ]
    },
    {
        "id": "a95ed85a5a8d87ae",
        "type": "sheet",
        "z": "2d72e3a85743de48",
        "name": "",
        "sheetName": "feuille1",
        "x": 890,
        "y": 220,
        "wires": [
            [
                "da6e244de92f56d6",
                "b54fb66e1296fa18"
            ]
        ]
    },
    {
        "id": "da6e244de92f56d6",
        "type": "cell",
        "z": "2d72e3a85743de48",
        "name": "",
        "address": "A1",
        "dataType": "w",
        "x": 1030,
        "y": 220,
        "wires": [
            [
                "ce1511dba0046374"
            ]
        ]
    },
    {
        "id": "8083a45afd8af295",
        "type": "file in",
        "z": "2d72e3a85743de48",
        "name": "",
        "filename": "C:\\Downloads\\test.xlsm",
        "filenameType": "str",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 390,
        "y": 220,
        "wires": [
            [
                "8c0b80d407f06452"
            ]
        ]
    },
    {
        "id": "8b9eb5ad0c063de7",
        "type": "inject",
        "z": "2d72e3a85743de48",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 220,
        "wires": [
            [
                "8083a45afd8af295"
            ]
        ]
    },
    {
        "id": "ce1511dba0046374",
        "type": "debug",
        "z": "2d72e3a85743de48",
        "name": "debug 15",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1160,
        "y": 220,
        "wires": []
    },
    {
        "id": "b54fb66e1296fa18",
        "type": "sheet-to-json",
        "z": "2d72e3a85743de48",
        "name": "",
        "raw": "false",
        "range": "A1:B2",
        "header": "default",
        "blankrows": false,
        "x": 1030,
        "y": 280,
        "wires": [
            [
                "2e73542474bd8c3c"
            ]
        ]
    },
    {
        "id": "2e73542474bd8c3c",
        "type": "debug",
        "z": "2d72e3a85743de48",
        "name": "debug 16",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1180,
        "y": 280,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [22 June 2023 16:36 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/10 "2023-06-22T16:36:43Z")

</div>

Set the read file node to `a single Buffer Object` and try again.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [23 June 2023 00:16 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/11 "2023-06-23T00:16:28Z")

</div>

Interesting, I might have a look at that some time. 👍

---

<div class="post-metadata">

**Author:** ![douchebagraccoon](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@douchebagraccoon](https://discourse.nodered.org/u/douchebagraccoon)\
**Post date:** [23 June 2023 06:42 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/12 "2023-06-23T06:42:24Z")

</div>

That worked! Thanks 🙂 Now to see about that drag and drop

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 August 2023 06:42 UTC](https://discourse.nodered.org/t/import-excel-file-and-read-data-from-it/79302/13 "2023-08-22T06:42:39Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
