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

182
Visualizações
How to format js strings to have a Google Sheet/Excel line break in a single cell?

Background

I'm trying to format some strings using plain JavaScript. It will be copy-pasted to a single cell in Google Sheet with a line break (alt + enter) in between. For example,

Sample Image

Code

let result = 'info1'
result += ', '         // replace with a line break
result += 'info2'

CopyToClipboard(result)

Problem

My closest attempt was using Google Sheet equation and char(10)

let result = '="info1"&char(10)&"info2"'

But since this solution changes the actual data, it's difficult to edit and reuse from the end-user perspective. I thought there must be a simpler way like /t and /n.

My not so successful tries include:

String.fromCharCode(10)

/r //r /n //n /t //t

Any advice would be appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use backslash \ but not slash /

\n

var result;

result = 'info1'
result += '\n'
result += 'info2'
/* OR */
result = 'info1\ninfo2'

Alternative: Template literals

let result = `info1
info2`;
about 4 years ago · Juan Pablo Isaza Relatório
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