# How to put the list data into new line in the same cell of excel

**URL:** https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058
**Category:** General
**Created:** [29 August 2022 09:43 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058 "2022-08-29T09:43:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![NeetaJ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/neetaj/32/60934_2.png) [@NeetaJ](https://discourse.nodered.org/u/NeetaJ)
#### Post date: [29 August 2022 09:43 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058/1 "2022-08-29T09:43:35Z")

</div>

Hi,

I have this below flow which takes the data and puts into excel and sends it as an attachment.

```auto
[{"id":"75213df52c14c49d","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"5d64f6b3253b286e","type":"function","z":"75213df52c14c49d","name":"","func":"msg.payload=\n [{\n \"No1\": \"101010101\", \n \"No2\":\"236482634763\", \n \"No3\": \"324523623\",\n \"No4\" : [\"11\",\"22\",\"32\",\"16\",\"102\"],\n \"No5\": [\"15\",\"236\",\"362\",\"87\"]\n }]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":120,"y":300,"wires":[["2155bee091949ab6","d5bc86d05379693c"]]},{"id":"2155bee091949ab6","type":"nanoid","z":"75213df52c14c49d","name":"","idLength":8,"property":"filename","propertyType":"msg","x":260,"y":300,"wires":[["185a201b05e8d807"]]},{"id":"185a201b05e8d807","type":"change","z":"75213df52c14c49d","name":"","rules":[{"t":"set","p":"filepath","pt":"msg","to":"'/tmp/'&filename&'.xlsx'","tot":"jsonata"},{"t":"set","p":"filename","pt":"msg","to":"filepath","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":300,"wires":[["e1f1cd60f8aea8fb"]]},{"id":"e1f1cd60f8aea8fb","type":"excel","z":"75213df52c14c49d","name":"","file":"/tmp/Details.xlsx","x":570,"y":300,"wires":[["5ac652da600e84dc"]]},{"id":"5ac652da600e84dc","type":"file in","z":"75213df52c14c49d","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":700,"y":300,"wires":[["1d4f39e4ef111f74"]]},{"id":"1d4f39e4ef111f74","type":"base64","z":"75213df52c14c49d","name":"","action":"str","property":"payload","x":860,"y":300,"wires":[["b79bb9dd8d53aae6"]]},{"id":"b79bb9dd8d53aae6","type":"template","z":"75213df52c14c49d","name":"Email body","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"message\": {\n \"subject\": \"Welcome letter\",\n \"body\": {\n \"content\": \"Hello\",\n \"contentType\": \"html\"\n },\n \"toRecipients\": [\n {\n \"emailAddress\": {\n \"address\": \"neeta.jadhav@global.ntt\",\n \"name\": \"Neeta Jadhav\"\n }\n }\n],\n \"attachments\": [\n {\n \"@odata.type\": \"#microsoft.graph.fileAttachment\",\n \"name\": \"details.xlsx\",\n \"contentBytes\": \"{{{payload}}}\"\n }\n]\n }\n}","output":"json","x":410,"y":380,"wires":[["462c7e725b1ab173","034229d7d7c23b8d"]]},{"id":"462c7e725b1ab173","type":"http request","z":"75213df52c14c49d","name":"Post to Microsoft Graph API","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://graph.microsoft.com/v1.0/me/sendMail","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":640,"y":380,"wires":[["e043a8183ed4cb47","fa05ace26c752e27"]]},{"id":"e043a8183ed4cb47","type":"exec","z":"75213df52c14c49d","command":"rm ","addpay":"filepath","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":830,"y":380,"wires":[["98157b38449d41c6"],[],[]]},{"id":"98157b38449d41c6","type":"debug","z":"75213df52c14c49d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":380,"wires":[]},{"id":"b6a27e12b4f50d4f","type":"inject","z":"75213df52c14c49d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":200,"wires":[["4898ccf62d6b7603"]]},{"id":"d5bc86d05379693c","type":"debug","z":"75213df52c14c49d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":190,"y":380,"wires":[]},{"id":"034229d7d7c23b8d","type":"debug","z":"75213df52c14c49d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":440,"wires":[]},{"id":"fa05ace26c752e27","type":"debug","z":"75213df52c14c49d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":440,"wires":[]},{"id":"4898ccf62d6b7603","type":"http request","z":"75213df52c14c49d","name":"Get Email Token","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://maplet-authrzr-0-1656663433.a927252e-fb71-472b-ae58-dce6bfd35690.svc:80/token/email","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":460,"y":180,"wires":[["efa8e7a3cdc63b37"]]},{"id":"efa8e7a3cdc63b37","type":"change","z":"75213df52c14c49d","name":"Set headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers['Authorization']","pt":"msg","to":"'Bearer ' & payload.accessToken","tot":"jsonata"},{"t":"set","p":"headers['Content-Type']","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":180,"wires":[["5d64f6b3253b286e"]]}]

```

Output is below

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0ca34a38d4fabb97de6f8174e977dc6378cc3974.png)

But expectation is to put the list in numbers in new line

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb7fff29e5346c057c8b3de3507ee6e4a440fca3.png)

Kindly help me on this topic.  
Hope I have provided all the required data.

Thanks,  
Neeta

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [29 August 2022 11:18 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058/2 "2022-08-29T11:18:39Z")

</div>

Have you tried sending a string with newlines in  
e.g.

```auto
msg.payload=
    [{
    "No1": "101010101", 
    "No2":"236482634763", 
    "No3": "324523623",
    "No4" : "11,\n22,\n32,\n16,\n102",
    "No5": ["15","236","362","87"]
    }]
return msg;

```

---

<div class="post-metadata">

### Author: ![NeetaJ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/neetaj/32/60934_2.png) [@NeetaJ](https://discourse.nodered.org/u/NeetaJ)
#### Post date: [29 August 2022 11:36 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058/3 "2022-08-29T11:36:36Z")

</div>

I have a dynamic data from api and now it works when I use .split(',').join('\n').  
Is it possible to put the data in new cell instead of same cell? as shown below

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/c/7cc303ec3d6ba0730964e2822f5c4614deb84990.png)

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [29 August 2022 11:46 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058/4 "2022-08-29T11:46:31Z")

</div>

Yes, but more complicated, you would need to generate a array element per spreadsheet row. After first row you would need to skip the no1,no2,no3. and no5 you would need to skip row 5.  
so you need your function to work out longest array, then use that array to loop and create rows skipping as above or if value is undefined. Hard to really say as we know nothing about your api return, or id no4 and no5 are variable in length.

---

<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: [12 September 2022 11:47 UTC](https://discourse.nodered.org/t/how-to-put-the-list-data-into-new-line-in-the-same-cell-of-excel/67058/5 "2022-09-12T11:47:18Z")

</div>

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