Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda