Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
Adding line breaks within a cell

I create a CSV from javascript array of objects using the json2csv module. This is what I do

const list = [{name: "xyz", city: "abc"},{name: "foo", city: "def"}];

const json2csvParser = new Parser({fields: headers});
const csv = json2csvParser.parse(list);

Now, for the CSV created by converting array of objects, I need to prepend a row (add a new row at the top) and fill only the first cell. It will look similar to the following

enter image description here

Here is what I tried:

const newLine = `"First Line
   Second Line"`;

const updatedCSV = newLine + csv;

Now, if I open this CSV using google spreadsheet, it shows the prepended value in cell, with line breaks. But if I open the same in Microsoft Excel, it shows as follows:

enter image description here

There are multiple rows created and " are also visible. How can I make it seamless, so that it opens the same everywhere, which always shows one row with multiple line breaks. I need to be able to add the line breaks within a cell.

I referred to

  • Adding a newline character within a cell (CSV)
  • Can you encode CR/LF in into CSV files?

but it did not help.

When I try to open the file using a text editor, this is how it looks like:

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!