Google-apps-script – How to display a progressbar in a Google Spreadsheet while a script is running

google-apps-script

Is it possible to display a progressbar in a Google Spreadsheet while a script is running (until it is finished)?
Something like JQuery progressbar would be fine, but on which selector?

Thanks in advance for any help!

$(document).ready(function(){    $('#Mydiv').progressbar({value: false} );})

Best Solution

the script you have is ok but if you want something intricate or complex, it will calculate percentages while the script is running

the CSS:

#progressbox {border: 1px solid #0099CC;padding: 1px;position:relative;width:400px;border-radius: 3px;margin: 10px;display:none;text-align:left;}#progressbar {height:20px;border-radius: 3px;background-color: #003333;width:1%;}#statustxt {top:3px;left:50%;position:absolute;display:inline-block;color: #000000;}

JQuery:

$(document).ready(function() {      var options = {            target:   '#output',            beforeSubmit:  beforeSubmit,            uploadProgress: OnProgress, //upload progress callback            success:       afterSuccess,            resetForm: true          };     $('#MyUploadForm').submit(function() {            $(this).ajaxSubmit(options);                       return false;        });});

The function below captures the arguments passed by form plugin, changing the width and text of progressbar real-time.

function OnProgress(event, position, total, percentComplete){    //Progress bar    progressbar.width(percentComplete + '%') //update progressbar percent complete    statustxt.html(percentComplete + '%'); //update status text    if(percentComplete>50)        {            statustxt.css('color','#fff'); //change status text to white after 50%        }}

@ref: http://www.sanwebe.com/2012/05/ajax-image-upload-with-progressbar-with-jquery-and-php

this deals with image uploads, but you can substitute it for scripts running in the background.