# Saving a JSON array in an excel file

**URL:** <https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531>\
**Category:** General\
**Created:** [12 July 2018 14:14 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531 "2018-07-12T14:14:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [12 July 2018 14:14 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/1 "2018-07-12T14:14:34Z")

</div>

Currently I'm doing a project where a sensor captures the distance in relation to time. My current problem lies in saving this data to an excel table, I am currently using this node ([https://flows.nodered.org/node/node-red-contrib-excel](https://flows.nodered.org/node/node-red-contrib-excel)), and this is giving me the result of the image sent, ![tabela](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/67bc10938a1b359a1980e61cb137366cee1192eb.PNG)

It's just a value for each column, would i like to know how I can solve this problem? would require that the distance be in one column and the time in another respectively.

![codigo](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/96ff6b5c2e8ec5e75475e6e53cbcdc51d6836a71.PNG)

![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/05f9acee5b18f72ada66a3615c7958f1c5908340.PNG)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [12 July 2018 14:26 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/2 "2018-07-12T14:26:00Z")

</div>

If you mean you want something like?

```
     distancia temp
     10 28
     20 38
     30 48

```

Then I think you need to store the data together and then send it to the excel node.

Another way of achieving an excel compatible file would be to write it as csv ( comma separated file)  
where you can create format each line and then add it to an existing file using the FILE-out node

---

<div class="post-metadata">

**Author:** ![gabrieldicieri](https://avatars.discourse-cdn.com/v4/letter/g/9dc877/32.png) [@gabrieldicieri](https://discourse.nodered.org/u/gabrieldicieri)\
**Post date:** [12 July 2018 14:56 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/3 "2018-07-12T14:56:30Z")

</div>

gonna try this, when i did i will answer you! thanks

---

<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:** [12 July 2018 23:14 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/4 "2018-07-12T23:14:06Z")

</div>

The csv node will convert well formed JSON into CSV which you can then easily save to a spreadsheet if needed.

---

<div class="post-metadata">

**Author:** ![kamal\_mohamed](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kamal\_mohamed](https://discourse.nodered.org/u/kamal_mohamed)\
**Post date:** [6 January 2019 22:21 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/5 "2019-01-06T22:21:08Z")

</div>

i tried your method but still can't get past on a single row

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [7 January 2019 07:24 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/6 "2019-01-07T07:24:24Z")

</div>

I have two solutions which on are you trying?

1. store the data and send once
2. Use the csv node

if it is 2 check that your file out node is configured to add/append data

---

<div class="post-metadata">

**Author:** ![kamal\_mohamed](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kamal\_mohamed](https://discourse.nodered.org/u/kamal_mohamed)\
**Post date:** [8 January 2019 18:01 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/7 "2019-01-08T18:01:16Z")

</div>

i tried the second it doesn't create the accurate format .. as for the first one i don't really know how to build a flow that send the file all at once

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [8 January 2019 18:14 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/8 "2019-01-08T18:14:45Z")

</div>

What is inaccurate with the format?

---

<div class="post-metadata">

**Author:** ![Ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@Ramya](https://discourse.nodered.org/u/Ramya)\
**Post date:** [22 February 2019 09:37 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/9 "2019-02-22T09:37:01Z")

</div>

Hi, I am new to node-red, can you give an example how to store the data together and send it to excel node, so that i can insert multiple rows into excel

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 February 2019 09:54 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/10 "2019-02-22T09:54:01Z")

</div>

@Ramya -  
Where are you getting the data from?  
What format is the date in?  
What have you tried so far?  
Show us your flow (read [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/3))

---

<div class="post-metadata">

**Author:** ![Ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@Ramya](https://discourse.nodered.org/u/Ramya)\
**Post date:** [4 March 2019 11:29 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/11 "2019-03-04T11:29:08Z")

</div>

I am hard-coding the json data in my function node,I can able to store the array of multiple json into excel , assume i have [{"key1":"a","key2":"b"},{"key3":"c","key4" : "d"}] but now can you help me how to strore the key1 and key2 into sheet1 of excel and key3 and key4 into sheet2 of excel.  
now i am storing key1, key2, key3, key4 all in one sheet of excel, which i dont want to do

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 March 2019 11:42 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/12 "2019-03-04T11:42:28Z")

</div>

i doubt the excel node can do that as it isn't mentioned in the readme

---

<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:** [4 March 2019 15:51 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/13 "2019-03-04T15:51:53Z")

</div>

You will need to rearrange the JSON somewhat.

Firstly, if you are using CSV, note that CSV files can only ever represent a single sheet. They have no concept of multiple sheets, you need multiple CSV files. You can use Excel to combine those files, especially if using newer versions of Excel. If your version of Excel has PowerQuery included then automatically combining a folder of CSV files into a single workbook is pretty easy. Even if not, it is relatively easy, especially with a bit of VBA for automation.

You could also do the automation using PowerShell if you are on a platform with support (it is available on Linux not just Windows these days). Because PowerShell supports .net natively, you can use the Excel libraries to combine data.

---

<div class="post-metadata">

**Author:** ![Ramya](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@Ramya](https://discourse.nodered.org/u/Ramya)\
**Post date:** [7 March 2019 10:58 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/14 "2019-03-07T10:58:41Z")

</div>

Thnaks a lot

---

<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:** [4 June 2022 11:19 UTC](https://discourse.nodered.org/t/saving-a-json-array-in-an-excel-file/1531/15 "2022-06-04T11:19:03Z")

</div>

2 posts were split to a new topic: [Process spreadsheet data per-row?](https://discourse.nodered.org/t/process-spreadsheet-data-per-row/63445)
