How to generate an HTML view in App Script from a Google Sheet - html

I have a client that uses Google forms to take orders and wants to be able to turn the resulting Sheet into a document of Packing Slips. Being a python person I am currently taking her .tsv and making nice HTML printable docs but want to be able to make a plug-in for her so that on any Sheet of this type she can click "Make Packing Slips" and it either opens a new tab with generated HTML (I'm ok using googles templating) or maybe even convert the HTML into a PDF and save it to her drive? Either way I'd rather design the document all in HTML and CSS rather than trying to make a google doc if at all possible. Is the feasible? Any starting points? Thanks!

You need to learn about Google App Script => https://developers.google.com/apps-script/overview
Then these Links should suffice
HTML Service: Create and Serve HTML
Google Container-bound Scripts for Google App Script (Can not post link for this due to low reputation)

Related

Put the URL (prepended with the text "Parent_") for a particular Google Doc into that Google Doc's own header and footer

Overview
Essentially I want to be able to migrate my Google Docs to a regular website while maintaining the links I had created between my Google Docs.
A proposed solution
What do you think about having a Google Apps Script put the URL (prepended with the text "Parent_") for a particular Google Doc into that Google Doc's own header and footer, once and only once, when that Google Doc is initially created? (I almost never use headers and footers therefore it seems like it might be reasonable to use them as if they were akin to fields in a database).
For example,
Create a Google Doc.
Let's say, that Google Doc, has the following URL https://docs.google.com/document/d/1XwCyQ2MAIJgcLwfmR9-_JQq97H9iVLbGXNbpbzq1-Oo/
Put Parent_https://docs.google.com/document/d/1XwCyQ2MAIJgcLwfmR9-_JQq97H9iVLbGXNbpbzq1-Oo/ into the header and footer.
That way when a Google Doc is exported as an HTML document, it will contain 2 instances of the following string: Parent_https://docs.google.com/document/d/1XwCyQ2MAIJgcLwfmR9-_JQq97H9iVLbGXNbpbzq1-Oo/ into the header and footer
Then, with a simple find/replace (RegEx) the HTML files could be relinked.
To be safe, I might run a Google Apps Script once a week to confirm that each Google Doc contained two instances of "Parent_" followed by the URL.
Finally, what if, say, once a week I were to export my Google Doc's as HTML files, upload them to a regular website, and run, say, a Python script to ensure that every Google Doc that contained "URL001" that was not prepended with "Parent_" actually linked to "Parent_URL001"
Fundamentally, it's a kludge. I know that. But I'm trying to circumvent, what is effectively, a "soft lock-in" feature in Google Docs for those who create hyperlinks between Google Docs.
My problem described in detail
Frequently I link one Google Doc to another Google Doc. As a result, I have created something that is similar to a wiki. For example let’s suppose I had created two Google Docs: Google Doc #1 and Google Doc #2.
Subsequently let’s suppose I had created a link (a hyperlink) in Google Doc #1 to Google Doc #2. Of course that's an extremely simple example. Let’s make it more complex. Imagine I had created a couple of thousand Google Docs with many links (hyperlinks) between them.
Of course backing up those Google Docs would be trivial either by using Google Takeout or rsync. However, what would happen if I wanted to move those Google Docs to a regular website? Then the myriad hyperlinks I had created would fail to point to the documents on my regular website.
That is, on my regular website, if I were to click on the link on the page which contained the contents which had been contained in Google Doc #1 (https://my_regular_website.com/google_doc_001) then instead of opening a link on my regular website to the page which contained the contents which had been contained in Google Doc #2 (https://my_regular_website.com/google_doc_002) , the link would point to the original Google Doc #2 (https://drive.google.com/drive/folders/google_**doc_002**)
Why not use Notion or at least a wiki?
I like using Google Docs as a word processor. Sometimes I use Google Docs to write essays. Sometimes I use Google Docs to create documentation. Sometimes I use Google Docs to collaborate with others (instead of emailing). Furthermore, I often use Google Docs’ outline format, styles, and voice typing.
As far as I know, neither Notion nor any wiki have all of the features listed above.

How do I reference a support file in Google Apps project

Is it possible to use a support file from within the apps script project as a source for iframe in another HTML.
I need to do this as a part of a Web App project in Google Apps Script.
Specifically I need it to work as a menu system which is the same across multiple pages, so that I don't have to repeat the same HTML code over and over again.
Better explained in a picture
Left side menu(buttons) stays the same across pages
There are several ways to accomplish what you are looking (" I don't have to repeat the same HTML code over and over again") but using iframe is not the best way when working with Google Apps Script web applications.
First you have to decide if you want to handle your web application as a multipage or as simple page.
In any case you might find helpful to use templated HTML / scriptlets to pass the code from Google Apps Script .html files to your main html code. If you find yourself scripts hard to start with, then you might use other methods of the HTML Service
Resources
https://developers.google.com/apps-script/guides/html/
https://developers.google.com/apps-script/guides/html/templates
https://developers.google.com/apps-script/reference/html
Related
Use project Javascript and CSS files in a Google Apps Script web app?
Recent related question (no answers at this time, but with comments)
HTML Service: Templated HTML as sidebar
Is it possible to create navigation bar on Google Apps Script?
how to connect a navigation bar (<nav>) with HTML files in google appscript?

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? :

Google App Script: Run script from within another script?

I am working on a payroll web app for my company. I was wondering if there is anyway to run a script from within another script. Such as having a hyperlink or something similar that the user could go and see a different UI and everything. If this is not possible, does anyone knows how to submit a copy of a html form to an email? I been trying to do this but GAS removes the styles and the JavaScript code that fills the form before sending it. I just need at least an image of the form so the manager could print it out and sign it.
Thanks
Yes, you can link from one script to another using regular anchors.
It's not Apps Script stripping your emailed form of this stuff. Email clients, including Gmail, intentionally don't support complex HTML. If you want an image, try creating a Google Doc with the DocumentsApp, converting it to pdf with document.getAs("application/pdf") and then emailing that.

Grab document text from Google Drive public document and display on Website

I just had an idea to have a collaboratively worked-on public Google Drive document's contents displayed on my Web site. I was hoping this would be straightforward, as I am only going to extract simple text and the document is public, so no authentication shenanigans will bar my way.
I have looked at Google Drive REST API, but turns out I can only get file metadata and/or the entire document file. Not just the document content.
I do not wish to spend a day coding to do this, I thought it would be nice to have, but can live with just linking into the file directly from my Web site. Anyone tried this before? Anyone experimented with Google Drive API and has a feel for how much work would be involved?
If you are thinking of getting the content of a native Google document (like a Google spreadsheet or a Google doc), this is currently possible with the Drive API.
In the Drive API, for Google native document types you will have a series of 'exportLinks' as part of the metadata of the file. Each of these export URLs allow you to download the content of the Google document in a specific export format (like RTF, plain text, HTML, PDF etc...). Updating my answer...
See the documentation for this: https://developers.google.com/drive/manage-downloads#downloading_google_documents