03-21-2023 09:53 AM
Hi Team,
I’m planning to write an excel file with statistics listed on it and I’ve been successful to record the counts from my previous snaps however at the end, the entire data comes as a long text which I would want to break it up.
For instance, I’m planning to write:
However, my output is coming as below:
Basically, I want line breaks in excel file I’m writing. Can we even achieve this in mapper snap?
Also, is it possible to define indentation (like Top/middle/bottom align, Left/Centre/Right align) while writing an excel file?
Thanking in advance for all the help 🙂
Best Regards,
Darsh
04-05-2023 06:41 AM
Hi, @darshthakkar -
I agree the Excel file format is a different story.
And there has to be a way to embed linefeeds in a field there, else you couldn’t do it in Excel itself and get the line breaks back when you reopen the file later!
I suggest if you don’t get an adequate answer in this forum, you check on a more general forum like Stack Exchange, and remove any references to SnapLogic. Just tell them you’re using an older version of JavaScript (not sure which one is embedded here, but I can find out if you really need it). Boil it down to just representing the line breaks in an Excel file (I guess you’re wanting .XLSX?), and how to get it in JavaScript.
Then apply here!
04-05-2023 06:47 AM
BTW, I saw you tried CHAR(10).
Did you try char(13)+char(10)?
Maybe just char(13)?
Or the inverse, char(10)+char(13)?
I’d try those – in that order – if you haven’t already.
04-05-2023 07:35 AM
In order to accomplish this, you will need to do two things, the first is in your mapper, where you want a new line, you’ll use a \n
in the string. You’ll have to do this with an expression-enabled field (you can’t type it out plain text without doing a later replacement of \\n
with \n
. Below is a screenshot from an example mapper (pipeline is attached at the bottom of this post)
The Second thing you will have to do is in excel, for any cell(s) that have line breaks, you’ll have to enable wrapping on said cells. This may differ based on your specific excel version, but on the mac version it’s under “Format Cells” → “Alignment” → “Text control:” → “Wrap text” (see screenshot below)
With all of these steps, you’ll see the excel now displays the new lines appropriately:
Excel New Line_2023_04_05.slp (5.2 KB)