You can use the rowHidden and columnHidden properties of the Range
class in case of Office web add-ins.
The columnHidden
property represents if all columns in the current range are hidden. Value is true when all columns in a range are hidden. Value is false when no columns in the range are hidden. Value is null when some columns in a range are hidden and other columns in the same range are not hidden.
The rowHidden
property represents if all rows in the current range are hidden. Value is true when all rows in a range are hidden. Value is false when no rows in the range are hidden. Value is null when some rows in a range are hidden and other rows in the same range are not hidden.
Using Office JavaScript API, you can programmatically hide and unhide rows by updating the rowHidden
property on the range object. The same can be applied to columns when using the columnHidden
property. For example:
Excel.run(function (context) {
// Hide rows 1-2 in 'Sheet1'
var range = context.workbook.worksheets.getItem("Sheet1").getRange("1:2");
range.rowHidden = true;
return context.sync()
.then(function() {
console.log("Rows 1-2 have been hidden.");
});
}).catch(function (error) {
console.log(error);
});