context.set

An alternative to changing individual properties using individual lines you can use the object.set method instead


set(properties: object, options: object)

object.set(properties [,options]) 

properties - either an object of the same Office.js type on which the method is called or a javascript object with property names and types that mirror the structure of the object.


options - can only be included when you provide a javascript object. The default value is true which is to threw an error if the javascript object includes any read only properties.


var _worksheet = context.workbook.worksheets.getItem("Sheet1"); 
var _range = _worksheet.getRange("A1:B2");
_range.set ( {
   format : {
      fill : {
         color : 'AAAAAA'
         },
      font : {
          name : 'Arial',
          color : 'white'
      }
    }
});


© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext