invitation india
UnexpectedWeb
Connect

Popular Technology Blog where you'll find some interesting things around the web, that you never knew existed.

link Link copied

Create new google spreadsheet if sheet exist in my spreatsheet

Share on: link Link copied
If you want to check if a certain spreadsheet (byName) exists or not, if not then create it. Now here i am find a sheet named "abonzer" , if not find then create it with 200 rows and 11 columns. Remaning cells Delete.
function initialize() {

   var ss = SpreadsheetApp.getActiveSpreadsheet();
   var mysheet = "abonzer";
   
   if (ss.getSheetByName(mysheet ) == null){
       ss.insertSheet('abonzer');
       var sheet = ss.getActiveSheet();
   
       sheet.deleteRows(200, 800);
       sheet.deleteColumns(11, 15);
   
    }
}

1 comment:

  1. function copyFromTemplate(){
    var templateSpreadsheet = SpreadsheetApp.openById(TEMPLATE_ID);
    var template = templateSpreadsheet.getSheets()[0]; //Assuming it is the first sheet

    //The default name will be "Copy of [original name]". We can use today's date to rename it
    var today = (new Date()).toDateString();

    var currentSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    template.copyTo(currentSpreadsheet).setName(today);
    }

    ReplyDelete

Powered by Blogger.