I'm trying to retrieve values from disjointed cells (RangeAreas) in an Excel web add-in but I'm struggling to figure out how to do so. In contiguous cells, I can use the "values" property of the Range class as follows:
let currentWorksheet = context.workbook.worksheets.getActiveWorksheet();
let foundRange = currentWorksheet.getRange("A1:A5").load("values");
return context.sync().then(function () {
console.log(JSON.stringify(foundRange.values));
});
How can I do that with disjointed cells on the RangeAreas class? I can't find this documented anywhere. This is my code to get a RangeAreas of disjointed cells and where I can successfully get their "address", but how can I get their "value"?
let currentWorksheet = context.workbook.worksheets.getActiveWorksheet(); // Get active worksheet
let foundRangeAreas = currentWorksheet.findAll("My Keyword", { completeMatch: false, matchCase: false });
foundRangeAreas.load("address");
return context.sync().then(function () {
console.log(JSON.stringify(foundRangeAreas.address));
});
CodePudding user response:
You could use RangeAreas.areas property which returns a collection of rectangular ranges and load values for each range:
foundRangeAreas.load("areas/values");