SoftTimur
SoftTimur

Reputation: 5510

Unhide and unprotect a workbook, all its worksheets and cells

Given a workbook, I want to unhide and unprotect the whole workbook including all its sheets, ranges and cells by JavaScript API.

For unhidding, I see visibility as a property of Worksheet, columnHidden, hidden and rowHidden as properties of Range. But is there any method to unhide them?

For unprotecting, there is unprotect() method of WorksheetProtection. Will applying this method to all the worksheets be sufficient to unprotect the whole workbook and everything inside?

Upvotes: 1

Views: 382

Answers (1)

Michael Zlatkovsky
Michael Zlatkovsky

Reputation: 8670

The .visibility of a worksheet refers to whether the worksheet itself is visible or hidden.

For hiding/unhiding a particular range: set columnHidden to true to hide, and false to show (unhide). Same goes for rowHidden.

Excel.run(function (ctx) {
    ctx.workbook.getSelectedRange().columnHidden = true;
    return ctx.sync();
});

For .unprotect(), yes, applying it to each worksheet should unprotect it all.

~ Michael Zlatkovsky, Developer on Office Extensibility Team, MSFT

Upvotes: 1

Related Questions