Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda