Google Spreadsheet parsing - html

I am publishing Google Spreadsheet table via File -> Publish to the Web ... Example published table here.
From this shared link I am parsing out a blank HTML table structure and display it on our website. I am removing all inline styles applied by Google.
Anyone knows if it is possible to:
Apply custom CSS class to cells inside Spreedheets that would google apply to the published HTML table?
Is it possible to defina a row inside a spreadsheet that would google publish as a <thead><tr><th></th></tr></thead>. For example I would like the first row to be a table header instead of table body.
Or any workarounds how to effectively style this table.

Related

Adding image to the SectionHeaderItem in Google Forms Apps script

I've been using Google Apps Scripts to generate Google Forms and sent be email.
However, i've been trying to add a logo to the header section however there is no function or a possible way that I can find online of adding it.
I can add images using ImageItem(), however, this does not add to the header section and stays as a single item at the start of the form.
Is there anyway of adding images to the header section using google apps script or thats only possible using the customizable UI made for designing google forms?
Assuming that for "header section" you mean the form header, the Forms Service doesn't include any class for the form header, so the only way to customize it is by using the Google Forms editor. By the other hand SectionHeaderItem, doesn't allow to insert images, only a title and a description.
Reference
https://developers.google.com/apps-script/reference/forms

Updating html of a Google Site's page with multiple blocks using Google Apps Script

I've created a page using "Web Page" template on my Google Sites, and I want to update the page using Google Apps Script. My code looks like this:
var template = HtmlService.createTemplateFromFile('mytemplate'); // meaning 'mytemplate.html'
var content = template.evaluate().getContent();
var site = SitesApp.getSiteByUrl('https://sites.google.com/site/example/');
var page = site.getChildByName('home');
page.setHtmlContent(content);
This works pretty well if the page's layout is "One column (simple)". Now my question is, if I choose one of the other layouts, how can I update each individual blocks using setHtmlContent()? Actually, I tried using "Two column (simple)" layout which has 2 blocks. setHtmlContent() changed the left column's html code and cleared the other column.
EDIT: What I actually wanted to do is to create a page with a gadget and update the page using Google Apps Script. According to this issue tracker https://code.google.com/p/google-apps-script-issues/issues/detail?id=572, it looks like we may encounter some problems when updating such page with setHtmlContent(). So I came up with an idea to create a multiple-column page, place a gadget in a column, and only update the HTML code of the other column with the Script to avoid such issue.
You can also create a Stand Alone Web App with Apps Script, then put an Apps Script Gadget into a Sites page. You can have multiple Apps Script Gadgets. I don't know what is triggering the change of the HTML. For all practical purposes, a Stand Alone Apps Script HTML Service App, is basically the same thing as a web site. You don't have a nice, understandable URL, but that won't show up in the Apps Script Gadget. Google will display a message: "This content was not created by Google"
I don't think you'll be able to inject HTML into multiple columns. You could create HTML that has multiple columns in it, and then add that HTML to the one column. So, you would be creating your own columns in HTML.

How to Add Hyperlinks to Google Forms user Google Apps Script

I'm trying to use Google Apps Script to add hyperlinked rows to a GridItem, ideally that act as tooltips. Am I trying to do more than is possible with Google Apps Script?
Here's the situation: I have a GridItem type question that has lengthy row descriptions. To clean up the interface, I'd like to present a short summary of the description that, when clicked/hovered, reveals the full text. To do this, I'd need to turn the short summary into a hyperlink. However, I haven't seen any way to insert hyperlinks in GridItem rows. I thought that Google Apps Script may allow me to do this.
So far, I've tried entering a string followed by .setLinkUrl(), using createAnchor('text', url), using markdown, and actually inserting, as text, <a href='http://google.com'>Google</a>' for the row. Nothing has worked so far.
Is this possible at all?
EDIT:
I apologize - I didn't research this question well enough before posting. Turns out Google Forms auto-detects URLs and posts them as links in the live form. I still have an issue with this, though - I'd rather have some specified text displayed to the user instead of the URL (some of my URLs are lengthy). Anyone know how to do this?
You can design the main elements of the Google form the normal way. Then preview the live form, copy the generated html file, hosted in your website.
Then you can replace the <a>...</a> tag that is generated by Google Form by one you need e.g. <a href='http://google.com'>Google</a>
keep sure you don't disturb any styles or code that may be needed by the Google form to work.
This solution need to have your own web hosting.
You will need to point your users to your website not the live form preview.

Google Apps Script add code to copy of a document

I created a document bound script in Google Docs that allows me to select a part of some text in a document. Then when I click my menu button it will make a copied document with only the selected text in it. The script then shares the copied document and emails the person that it was shared with them.
I would like it to be possible that the user of the shared document is able to read that document, and send a message back via a form on what he thought about it. So he would also go to a customized menu button, click on it, a form would pop up and he would email me back with the text.
I know how to do this in Google Apps Script manually. I can go to the copied document and just add that script. But how do I automize this? I looked at the Google Apps Script references but could not find anything.
It is not possible to embed a script in a document using a script.
You could use a template that has a script , make a copy of it and add your content to that copy instead of creating the new doc from scratch.
Depending on the document content it might be very simple ...or just a bit more complex since you will have to add each element in turn. There are a few examples of this process here: How to copy a template and insert content from another document? :

How to style a Google Doc using Google Drive API?

Currently, I have a web application that basically consists in a simple form. When I submit this form, I generate a document that I send to Google Drive. It works.
My problem is that I have no styling and I wonder how I can do that? I tried with HTML and CSS but if the HTML allows me to structure my document, the CSS does nothing.
So, how could I do that?
I guess you're uploading an HTML file, with convert=true, to create a Google Doc. Any "attached" CSS file will be ignored. There is some embedded element styling that will be honoured by the conversion process. Perhaps the best approach would be to create a sample styled document manually, then export it as HTML to see how the styling works.