0

I'm practicing a little bit google script and I want to automate some boring stuff. I have a spreadsheet where I have 10 columns. And to automate adding new values into it I have created userform.

function showUserForm() {

  var template = HtmlService.createTemplateFromFile("userform")

  var html = template.evaluate()
  html.setTitle("Dodawanie nowej mikroderogi").setHeight(600).setWidth(500);

  SpreadsheetApp.getUi().showModalDialog(html, "System");

}

function appendData(data){
  var ss = SpreadsheetApp.openByUrl(url);
  var ws = ss.getSheetByName("2019"); 
  //var lastRow = sheet.getLastRow();


  ws.appendRow(["",data.choice, data.model,"", data.description, data.defect, data.size, data.qty, data.mqa, data.paint, data.ass]);  

}

And now I have few questions

  1. In first column I want to add some formula to generate signature. I have such formula in spreadsheet, I take year and next number, but how can I refer to last row?

  2. In fourth column I want to add vlookup formula to search through list in different sheet. And I have same problems like in previous point

  3. Now something more sophisticated. I wish to add option to draw on canvas. But not on blank one. I want to upload photo (did that) and use it as background of canva, and after editing photo I would like to save this file on my google drive. Is it even possible?

  4. How to add photos into spreadsheet using google script? I mean, I want to store not link but real photo. And import it later to another sheet (through signature)

Here is what I have done already in HTML

  <html>
    <head>
      <!--Import Google Icon Font-->
      <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
      <!-- Compiled and minified CSS -->
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

      <!--Let browser know website is optimized for mobile-->
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    </head>

    <body>
    <div class="container">
    <div class = "row">
    <div class="input-field col s6">
    <input id="wybdate" type="text" class="datepicker" required>
    <label for="wybdate">Date choice</label>
    </div>
    </div>
    <div class="row">
    <div class="input-field col s6">
    <select id="multi" class = "validate" required>
    <option value="" disabled selected>Model choice</option>
    <option value="W10875642">First</option>
    <option value="W11035532">Second</option>
    <option value="W10903795">Third</option>
    <option value="W11035531">Fourth</option>
    <option value="W10866527">Fifth</option>
    <option value="W11033841">Sixth</option>
    <option value="W11025835">Seventh</option>
    <option value="W10874036">Eighth</option>
    </select>
    </div>
    <div class="input-field col s6">
      <input id="ile" type="number" class="validate" required>
      <label class="active" for="ile">Quantity</label>
    </div>
    <div class="input-field col s12">
      <input id="opis" type="text" class="validate" required>
      <label for="opis">Description</label>
    </div>

    <div class="input-field col s12">
    <input id="dzj" type="text" class="validate" required>
    <label for="dzj">MQA</label>
    </div>
    <div class="input-field col s12">
      <input id="lakiernia" type="text" class="validate" required>
      <label class="active" for="lakiernia">Painting Line</label>
    </div>
    <div class="input-field col s12">
      <input id="linia" type="text" class="validate" required>
      <label class="active" for="linia">Ass</label>
    </div>
        </div>
    </div>
    <div class="container">
        <form action="#">
    <div class="file-field input-field">
      <div class="btn">
        <span>file</span>
        <input type="file" id="defplik" required >
      </div>
      <div class="file-path-wrapper">
        <input class="file-path validate" type="text" id="defekt" required>
        <label for="defekt">Place</label>
      </div>
    </div>
    <p class="range-field">
      <input type="range" id="rozmiar" min="0" max="30" value="0" pattern="[1-30]" required>
      <label for="rozmiar">Size (in mm)</label>
    </p>
    </form>
    </div>



    <div class="input-field col s12">
    <button class="btn waves-effect waves-light" id="btn" required>add
    <i class="material-icons right">send</i>
    </button>
    </div>
  • Try [Range.setFormula()](https://developers.google.com/apps-script/reference/spreadsheet/range#setFormula(String)). – Cooper Jul 08 '19 at 21:36
  • "how can I refer to last row?" `getLastRow()`[Google Docs](https://developers.google.com/apps-script/reference/spreadsheet/sheet#getlastrow) – Tedinoz Jul 09 '19 at 12:08
  • "How to add photos into spreadsheet using google script? I mean, I want to store not link but real photo." You want [Google Drive](https://developers.google.com/apps-script/reference/drive/). You might also read [Saving image to Spreadsheet with Google Scripts](https://stackoverflow.com/q/43054790/1330560) or [Insert Image into Spresheet Cell from Drive using Google Apps Script](https://stackoverflow.com/q/41020598/1330560). – Tedinoz Jul 09 '19 at 12:15

0 Answers0