Snippets - Formulas

entering with INDIRECT ?



Formulas - Writing

Excel.run(function (context) { 
                context.workbook.worksheets.getActiveWorksheet().getRange("A1:C3").formulas = "=RAND()*17";
                return context.sync();
}).catch(function (error) {
   console.log(error);
});

Excel.run(function (context) {
                var range = context.workbook.worksheets.getItem("Sheet1").getRange("A1:B2");
                range.formulas = [["=RAND()*12", "=RAND()*19"], ["=A1*.7", "=B1*.9"]];
                return context.sync();
}).catch(function (error) {
   console.log(error);
});

Formulas - Reading

Excel.run(function (context) { 
                var range = context.workbook.worksheets.getActiveWorksheet().getRange("A1:C3").load("formulas");
                return context.sync().then(function() {
                                for (var i = 0; i < range.formulas.length; i++) {
                                                for (var j = 0; j < range.formulas[i].length; j++) {
                                                                console.log(range.formulas[i][j]);
                                                }
                                }
                                console.log("done");
                });
}).catch(function (error) {
   console.log(error);
});

Formulas - read calculation mode

Excel.run(function (context) { 
                var application = context.workbook.application.load("calculationMode");
                return context.sync().then(function () {
                                console.log(application.calculationMode);
                });
}).catch(function (error) {
   console.log(error);
});

Formulas - calculate workbooks

Excel.run(function (context) { 
                context.workbook.application.calculate(Excel.CalculationType.full);
                return context.sync();
}).catch(function (error) {
   console.log(error);
});




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