Bernie Howard
Bernie Howard

Reputation: 3

Can't add line breaks to google script

I have a google sheet with the text I wish to use in an email. The sheet has 50 rows and 3 columns of text, formatted as required. I have written code that will grab the sheet contents, but it doesn't have line feeds where I want them (funnily enough, at the end of the lines) It returns the sheet data as one lump of text.

I have tried \n and char(10)

var EmailLines = sSheet.getRange(startRow, startCol, numRows).getValues();

I thought it might be a simple add the LF at the end of each line but the array doesn't recognise line feeds ?

Upvotes: 0

Views: 322

Answers (1)

Cooper
Cooper

Reputation: 64032

Try:

var text=EmailLines.join('\r\n');

Upvotes: 1

Related Questions