title: Initiate a download from google apps script
body: <p>I added a new menu item to my spreadsheet using google apps script. This menu item creates a file, but I'd like for it to initiate the download of the file after creating it.</p>
  
  <p>Is this possible?</p>
  
  <p>Remember, this is not a web app, but a menu item in my spreadsheet.</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Thanks to Serge insas' suggestion, the following simple script works perfectly, and opens a download window with the link I need:</p>
  
  <pre><code>function onOpen() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var csvMenuEntries = [ {name: "Zip all CSVs", functionName: "saveAsCSV"} ];
    ss.addMenu("CSV", csvMenuEntries);
  };
  
  function saveAsCSV() {
    var folder = createCSVs(); // creates a folder with CSV for each Sheet
    var zipFile = zipCSVs(folder, "DI.zip"); // creates a zip of all CSVs in folder
  
    var ui = UiApp.createApplication().setTitle("Download");
    var p = ui.createVerticalPanel();
    ui.add(p);
    p.add(ui.createAnchor("Download", zipFile.getDownloadUrl()));
    SpreadsheetApp.getActive().show(ui)
  }
  </code></pre>