Snippets


Copy the values from Range A1:A2 on the active worksheet to B1:B2.
Assign the previously loaded values to the new range proxy object.
The values will be updated once the following .then() function is invoked.

Excel.run(function (context) { 
    var _range = context.workbook.worksheets.getActiveWorksheet().getRange("A1:A2");
    _range.load ("address, values, range/format");
    _return context.sync().then(function() {
        context.workbook.worksheets.getActiveWorksheet().getRange("B1:B2").values= range.values;
    });
}).then(function() {
      console.log("done");
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});

Excel.run(function (context) { 
    var _sheetName = "Sheet1";
    var _rangeAddress = "A1:B2";
    var _myRange = context.workbook.worksheets.getItem(_sheetName).getRange(_rangeAddress);
    _myRange.load(["address", "format/*", "format/fill", "entireRow" ]);
    return context.sync().then(function() {
        console.log (myRange.address);
        console.log (myRange.format.wrapText);
        console.log (myRange.format.fill.color);
        //console.log (myRange.format.font.color); //not loaded
    });
}).then(function() {
      console.log("done");
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});


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