How to maintain HTML mark -up as-is in an google sheet cell without breaking the html tagAndroid get text from htmlGet the last non-empty cell in a column in Google SheetsGoogle Sheet script set cell valueHow to add a value of a tag to the href of another tag using only HTML (no script)Cannot display HTML stringExport Google sheet to pdf without notesImport Gmail Message to Google Sheet as text so it falls into Cellsaccess a google sheet entry from the embedded html file siteGoogle Sheets conditional combine, clear all cells in range, Loop. VBA to JSGoogle Sheets Get cell value and column header value if cell background color is true and join them as string

Do you waste sorcery points if you try to apply metamagic to a spell from a scroll but fail to cast it?

Can I run 125kHz RF circuit on a breadboard?

How to preserve electronics (computers, iPads and phones) for hundreds of years

What is the meaning of the following sentence?

How do you justify more code being written by following clean code practices?

What (the heck) is a Super Worm Equinox Moon?

In One Punch Man, is King actually weak?

Giving feedback to someone without sounding prejudiced

Proving an identity involving cross products and coplanar vectors

"Oh no!" in Latin

Language involving irrational number is not a CFL

Make a Bowl of Alphabet Soup

Would a primitive species be able to learn English from reading books alone?

Would this string work as string?

Difference between shutdown options

Personal or impersonal in a technical resume

Deciphering cause of death?

How to make a list of partial sums using forEach

Do I have to know the General Relativity theory to understand the concept of inertial frame?

What does "tick" mean in this sentence?

Usage of an old photo with expired copyright

Is there anyway, I can have two passwords for my wi-fi

Is there a RAID 0 Equivalent for RAM?

What the heck is gets(stdin) on site coderbyte?



How to maintain HTML mark -up as-is in an google sheet cell without breaking the html tag


Android get text from htmlGet the last non-empty cell in a column in Google SheetsGoogle Sheet script set cell valueHow to add a value of a tag to the href of another tag using only HTML (no script)Cannot display HTML stringExport Google sheet to pdf without notesImport Gmail Message to Google Sheet as text so it falls into Cellsaccess a google sheet entry from the embedded html file siteGoogle Sheets conditional combine, clear all cells in range, Loop. VBA to JSGoogle Sheets Get cell value and column header value if cell background color is true and join them as string













1















I am trying to use google sheet to add complete HTML of an email in a cell where I have variables for text, image src, href src etc.



Now I am using google script to replace tags with the values so that I can copy the complete html and paste it in the email marketing system.



I am doing this because my email marketing system does not support variables.



But, I have noticed, when I paste HTML template markup in a cell, the google sheet adds an extra set of "" around the existing "".



For example, if this is the HTML I paste:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://www.Google.com">Visit Google</a>


</body>
</html>


This will be changed into this:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href=""https://www.Google.com"">Visit Google</a>


</body>
</html>


Notice:



<a href="https://www.Google.com">Visit Google</a>


Google sheet is adding extra set ok "" around my href src. Same problem with all the tags.



<a href=""https://www.Google.com"">Visit Google</a>


My concern is if google sheet can maintain html as-is in a cell or not? Any solution to this problem?










share|improve this question






















  • 1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

    – TheMaster
    Mar 7 at 22:22











  • Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

    – kuml
    Mar 7 at 22:52











  • Using script editor won't solve the problem that I'm looking to solve.

    – kuml
    Mar 7 at 22:53











  • developers.google.com/apps-script/reference/html/html-template

    – TheMaster
    Mar 7 at 23:01











  • Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

    – kuml
    Mar 7 at 23:49















1















I am trying to use google sheet to add complete HTML of an email in a cell where I have variables for text, image src, href src etc.



Now I am using google script to replace tags with the values so that I can copy the complete html and paste it in the email marketing system.



I am doing this because my email marketing system does not support variables.



But, I have noticed, when I paste HTML template markup in a cell, the google sheet adds an extra set of "" around the existing "".



For example, if this is the HTML I paste:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://www.Google.com">Visit Google</a>


</body>
</html>


This will be changed into this:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href=""https://www.Google.com"">Visit Google</a>


</body>
</html>


Notice:



<a href="https://www.Google.com">Visit Google</a>


Google sheet is adding extra set ok "" around my href src. Same problem with all the tags.



<a href=""https://www.Google.com"">Visit Google</a>


My concern is if google sheet can maintain html as-is in a cell or not? Any solution to this problem?










share|improve this question






















  • 1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

    – TheMaster
    Mar 7 at 22:22











  • Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

    – kuml
    Mar 7 at 22:52











  • Using script editor won't solve the problem that I'm looking to solve.

    – kuml
    Mar 7 at 22:53











  • developers.google.com/apps-script/reference/html/html-template

    – TheMaster
    Mar 7 at 23:01











  • Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

    – kuml
    Mar 7 at 23:49













1












1








1








I am trying to use google sheet to add complete HTML of an email in a cell where I have variables for text, image src, href src etc.



Now I am using google script to replace tags with the values so that I can copy the complete html and paste it in the email marketing system.



I am doing this because my email marketing system does not support variables.



But, I have noticed, when I paste HTML template markup in a cell, the google sheet adds an extra set of "" around the existing "".



For example, if this is the HTML I paste:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://www.Google.com">Visit Google</a>


</body>
</html>


This will be changed into this:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href=""https://www.Google.com"">Visit Google</a>


</body>
</html>


Notice:



<a href="https://www.Google.com">Visit Google</a>


Google sheet is adding extra set ok "" around my href src. Same problem with all the tags.



<a href=""https://www.Google.com"">Visit Google</a>


My concern is if google sheet can maintain html as-is in a cell or not? Any solution to this problem?










share|improve this question














I am trying to use google sheet to add complete HTML of an email in a cell where I have variables for text, image src, href src etc.



Now I am using google script to replace tags with the values so that I can copy the complete html and paste it in the email marketing system.



I am doing this because my email marketing system does not support variables.



But, I have noticed, when I paste HTML template markup in a cell, the google sheet adds an extra set of "" around the existing "".



For example, if this is the HTML I paste:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://www.Google.com">Visit Google</a>


</body>
</html>


This will be changed into this:



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href=""https://www.Google.com"">Visit Google</a>


</body>
</html>


Notice:



<a href="https://www.Google.com">Visit Google</a>


Google sheet is adding extra set ok "" around my href src. Same problem with all the tags.



<a href=""https://www.Google.com"">Visit Google</a>


My concern is if google sheet can maintain html as-is in a cell or not? Any solution to this problem?







html google-apps-script google-sheets google-apps google-sheets-formula






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 22:08









kumlkuml

134




134












  • 1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

    – TheMaster
    Mar 7 at 22:22











  • Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

    – kuml
    Mar 7 at 22:52











  • Using script editor won't solve the problem that I'm looking to solve.

    – kuml
    Mar 7 at 22:53











  • developers.google.com/apps-script/reference/html/html-template

    – TheMaster
    Mar 7 at 23:01











  • Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

    – kuml
    Mar 7 at 23:49

















  • 1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

    – TheMaster
    Mar 7 at 22:22











  • Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

    – kuml
    Mar 7 at 22:52











  • Using script editor won't solve the problem that I'm looking to solve.

    – kuml
    Mar 7 at 22:53











  • developers.google.com/apps-script/reference/html/html-template

    – TheMaster
    Mar 7 at 23:01











  • Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

    – kuml
    Mar 7 at 23:49
















1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

– TheMaster
Mar 7 at 22:22





1.Use single quotes. 2. Why not directly paste it in script editor as a html file?

– TheMaster
Mar 7 at 22:22













Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

– kuml
Mar 7 at 22:52





Because I'm creating this sheet to edit content in the HTML easily for users. Who can simple add values in the variable and on button click, my script will replace variable with values in the HTML.

– kuml
Mar 7 at 22:52













Using script editor won't solve the problem that I'm looking to solve.

– kuml
Mar 7 at 22:53





Using script editor won't solve the problem that I'm looking to solve.

– kuml
Mar 7 at 22:53













developers.google.com/apps-script/reference/html/html-template

– TheMaster
Mar 7 at 23:01





developers.google.com/apps-script/reference/html/html-template

– TheMaster
Mar 7 at 23:01













Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

– kuml
Mar 7 at 23:49





Hi @TheMaster I am not 100% sure how to use the html-template from the doc. Is there any example / steps to follow? Just fyi.. I am not trying ton construct HTML, I already have HTML of full email template. Just trying to find an easy way for users to add value in variables in google sheet, and a button script will execute the script that will find variables in the HTML code and replace it. So users can paste the new updated HTML code and use it in email marketing system.

– kuml
Mar 7 at 23:49












1 Answer
1






active

oldest

votes


















0














Try this:



//Just enter the strings shown below into those cells in Sheet1 which no quotations and then run the script and you'll see your html
//A1=My First Heading
//A2=My first paragraph.
//A3=http://google.com
//A4=Visit Google

function displayEmailHtml()
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html><html><body><h1>%s</h1><p>%s</p><a href="%s">%s</a>/body></html>',vA[0][0],vA[1][0],vA[2][0],vA[3][0]);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



To answer your second question try this:



function displayEmailHtml() 
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html>n<html>n<body>n<h1>%s</h1>n<p>%s</p>',vA[0][0],vA[1][0]);
html+=Utilities.formatString('n<a href="%s">%s</a>n</body>n</html>',vA[2][0],vA[3][0]);
html=html.replace(/>/g,'&gt');
html=html.replace(/</g,'&lt');
html=Utilities.formatString('<pre>%s</pre>',html);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



  • Utilities.formatString()





share|improve this answer

























  • Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

    – kuml
    Mar 8 at 2:37











  • @kuml Take a look at the edit to my answer.

    – Cooper
    Mar 8 at 2:57











  • Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

    – kuml
    Mar 8 at 3:07











  • Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

    – kuml
    Mar 8 at 3:10











  • I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

    – kuml
    Mar 8 at 3:15










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053589%2fhow-to-maintain-html-mark-up-as-is-in-an-google-sheet-cell-without-breaking-the%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Try this:



//Just enter the strings shown below into those cells in Sheet1 which no quotations and then run the script and you'll see your html
//A1=My First Heading
//A2=My first paragraph.
//A3=http://google.com
//A4=Visit Google

function displayEmailHtml()
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html><html><body><h1>%s</h1><p>%s</p><a href="%s">%s</a>/body></html>',vA[0][0],vA[1][0],vA[2][0],vA[3][0]);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



To answer your second question try this:



function displayEmailHtml() 
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html>n<html>n<body>n<h1>%s</h1>n<p>%s</p>',vA[0][0],vA[1][0]);
html+=Utilities.formatString('n<a href="%s">%s</a>n</body>n</html>',vA[2][0],vA[3][0]);
html=html.replace(/>/g,'&gt');
html=html.replace(/</g,'&lt');
html=Utilities.formatString('<pre>%s</pre>',html);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



  • Utilities.formatString()





share|improve this answer

























  • Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

    – kuml
    Mar 8 at 2:37











  • @kuml Take a look at the edit to my answer.

    – Cooper
    Mar 8 at 2:57











  • Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

    – kuml
    Mar 8 at 3:07











  • Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

    – kuml
    Mar 8 at 3:10











  • I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

    – kuml
    Mar 8 at 3:15















0














Try this:



//Just enter the strings shown below into those cells in Sheet1 which no quotations and then run the script and you'll see your html
//A1=My First Heading
//A2=My first paragraph.
//A3=http://google.com
//A4=Visit Google

function displayEmailHtml()
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html><html><body><h1>%s</h1><p>%s</p><a href="%s">%s</a>/body></html>',vA[0][0],vA[1][0],vA[2][0],vA[3][0]);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



To answer your second question try this:



function displayEmailHtml() 
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html>n<html>n<body>n<h1>%s</h1>n<p>%s</p>',vA[0][0],vA[1][0]);
html+=Utilities.formatString('n<a href="%s">%s</a>n</body>n</html>',vA[2][0],vA[3][0]);
html=html.replace(/>/g,'&gt');
html=html.replace(/</g,'&lt');
html=Utilities.formatString('<pre>%s</pre>',html);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



  • Utilities.formatString()





share|improve this answer

























  • Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

    – kuml
    Mar 8 at 2:37











  • @kuml Take a look at the edit to my answer.

    – Cooper
    Mar 8 at 2:57











  • Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

    – kuml
    Mar 8 at 3:07











  • Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

    – kuml
    Mar 8 at 3:10











  • I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

    – kuml
    Mar 8 at 3:15













0












0








0







Try this:



//Just enter the strings shown below into those cells in Sheet1 which no quotations and then run the script and you'll see your html
//A1=My First Heading
//A2=My first paragraph.
//A3=http://google.com
//A4=Visit Google

function displayEmailHtml()
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html><html><body><h1>%s</h1><p>%s</p><a href="%s">%s</a>/body></html>',vA[0][0],vA[1][0],vA[2][0],vA[3][0]);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



To answer your second question try this:



function displayEmailHtml() 
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html>n<html>n<body>n<h1>%s</h1>n<p>%s</p>',vA[0][0],vA[1][0]);
html+=Utilities.formatString('n<a href="%s">%s</a>n</body>n</html>',vA[2][0],vA[3][0]);
html=html.replace(/>/g,'&gt');
html=html.replace(/</g,'&lt');
html=Utilities.formatString('<pre>%s</pre>',html);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



  • Utilities.formatString()





share|improve this answer















Try this:



//Just enter the strings shown below into those cells in Sheet1 which no quotations and then run the script and you'll see your html
//A1=My First Heading
//A2=My first paragraph.
//A3=http://google.com
//A4=Visit Google

function displayEmailHtml()
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html><html><body><h1>%s</h1><p>%s</p><a href="%s">%s</a>/body></html>',vA[0][0],vA[1][0],vA[2][0],vA[3][0]);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



To answer your second question try this:



function displayEmailHtml() 
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Sheet1');
var rg=sh.getRange(1,1,4,1);
var vA=rg.getValues();
var html=Utilities.formatString('<!DOCTYPE html>n<html>n<body>n<h1>%s</h1>n<p>%s</p>',vA[0][0],vA[1][0]);
html+=Utilities.formatString('n<a href="%s">%s</a>n</body>n</html>',vA[2][0],vA[3][0]);
html=html.replace(/>/g,'&gt');
html=html.replace(/</g,'&lt');
html=Utilities.formatString('<pre>%s</pre>',html);
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModelessDialog(userInterface, 'My Email Html');



  • Utilities.formatString()






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 5:23

























answered Mar 7 at 23:49









CooperCooper

7,9692829




7,9692829












  • Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

    – kuml
    Mar 8 at 2:37











  • @kuml Take a look at the edit to my answer.

    – Cooper
    Mar 8 at 2:57











  • Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

    – kuml
    Mar 8 at 3:07











  • Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

    – kuml
    Mar 8 at 3:10











  • I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

    – kuml
    Mar 8 at 3:15

















  • Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

    – kuml
    Mar 8 at 2:37











  • @kuml Take a look at the edit to my answer.

    – Cooper
    Mar 8 at 2:57











  • Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

    – kuml
    Mar 8 at 3:07











  • Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

    – kuml
    Mar 8 at 3:10











  • I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

    – kuml
    Mar 8 at 3:15
















Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

– kuml
Mar 8 at 2:37





Hi @Cooper thank you for the code. It does work and it is great. In my use-case, I am not looking to get HTML output. I would like to display the raw html markup after the update has been done. How can we do that?

– kuml
Mar 8 at 2:37













@kuml Take a look at the edit to my answer.

– Cooper
Mar 8 at 2:57





@kuml Take a look at the edit to my answer.

– Cooper
Mar 8 at 2:57













Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

– kuml
Mar 8 at 3:07





Thank you @Cooper for the update. it is working and that's exactly what I am look for. Question for you: In this approach we are following the order approach in which 1st variable relates to 1st cell value, second variable relates to 2nd cell value and so on...Is it possible to assign variables like "heading1", "href_url", "button_text" etc? Second question is: Where this is coming from "%s"? is it declared somewhere? why "%s"?

– kuml
Mar 8 at 3:07













Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

– kuml
Mar 8 at 3:10





Since we are following sequential approach, if we have one line like <a href="%s">%s</a> is this approach going to be very accurate and always replace whatever variable comes first even if we have a number of variables in the same line?

– kuml
Mar 8 at 3:10













I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

– kuml
Mar 8 at 3:15





I also testing adding the whole email template. Since email template HTML code is quite a lot as compared to just one line, only one line is coming in the output. It might be a lot of work to put together whole html template in one single and not sure if that will work or not as complete HTML email template may have a lot of tags, special characters etc. Your thoughts? any way to make improvements to support full HTML email template?

– kuml
Mar 8 at 3:15



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053589%2fhow-to-maintain-html-mark-up-as-is-in-an-google-sheet-cell-without-breaking-the%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme