# Xlsx file to json using function

**URL:** <https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254>\
**Category:** General\
**Tags:** function-node\
**Created:** [6 February 2024 11:41 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254 "2024-02-06T11:41:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbadshahp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hbadshahp/32/87915_2.png) [@hbadshahp](https://discourse.nodered.org/u/hbadshahp)\
**Post date:** [6 February 2024 11:41 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/1 "2024-02-06T11:41:20Z")

</div>

Hii everyone,

I am new to NodeRed. I want to iterate through the Row whose first column is matching with my Input. Shall writing function for these is good choice.

[flows.json](https://discourse.nodered.org/uploads/short-url/fpa0AW3ds4UfvQqH1Af72PaoYA6.json) (1.6 KB)

![Screenshot 2024-02-06 170627](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e63e6214e4ece7f0de4b9f408a7a41331a8133a4.png)

---

<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:** [6 February 2024 12:41 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/2 "2024-02-06T12:41:43Z")

</div>

Node-red has several contributed nodes for reading Excel/CSV and converting to JSON. Alternatively, you can use a node.js package with a function node which is what I tend to do with more complex needs as in this example where I needed to convert a flat table into a hierarchy:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52cbc36e4c79c0bb264d292745258dd718330738.png)

The function node automatically `require`s the libraries so that the names in the "import as" column are available as constants in your function node code.

---

<div class="post-metadata">

**Author:** ![hbadshahp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hbadshahp/32/87915_2.png) [@hbadshahp](https://discourse.nodered.org/u/hbadshahp)\
**Post date:** [7 February 2024 05:02 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/3 "2024-02-07T05:02:54Z")

</div>

Shall you suggest some example how to use node.js package with a function node in node-red.

---

<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:** [7 February 2024 06:50 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/4 "2024-02-07T06:50:50Z")

</div>

I am using [node-red-contrib-spreadsheet-in](https://flows.nodered.org/node/node-red-contrib-spreadsheet-in) works great - it can read all properties from each sheet, cell etc, including styling formulas etc. There is a specific node to get a json object/array from a sheet.

---

<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:** [7 February 2024 09:31 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/5 "2024-02-07T09:31:28Z")

</div>

AlaSQL should also work and I think that has a node though not sure if it is still being updated.

---

<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:** [7 May 2024 09:31 UTC](https://discourse.nodered.org/t/xlsx-file-to-json-using-function/85254/6 "2024-05-07T09:31:29Z")

</div>

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