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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page