I have a script on Google app script. This script find a data simply.
my code :
var content=this.spreadsheet.getSheetByName("sheet1").getRange("C1:C26").getValues();
this.summary = contents[4][0];
I find my data , no prob but , my data has line breaks and my webpage on Google sites shows the result without line breaks.
It's a prob of convert with GetValue () ?
my data on a Cell of Spreadsheet :
blabab---
bla
abla---
bla
the result on a Google Site
blabab---bla abla---bla
The solution is the following:
\n
) in the string with the HTML version (<br />
)Something like the following:
function lineBreakTest() {
var cellWithLineBreaks = SpreadsheetApp.getActiveSheet().getRange("a1").getValue();
Logger.log(cellWithLineBreaks);
cellWithLineBreaks = cellWithLineBreaks.replace(/\n/g, '<br>');
Logger.log(cellWithLineBreaks);
// Post to your Google Site here. Logger.log is just used to demonstrate.
}
The reason you have to do this is because Spreadsheets uses normal text line breaks \n
in its cells. However, Google sites uses HTML format, so you need to do the 'conversion'. This answer is also a helpful source.