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

184
Views
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 answers
Answer question

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 Report
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!