none
Is it possible for an Excel Task Pane add-in to make cells read-only to the end-user (but writable by JS code)? RRS feed

  • Question

  • My Task Pane add-in for Excel gets tabular data from an external data source, renders it in a table in the worksheet, allows the end-user to edit the data, and then sends the edited data back to the external data source.  Some of the data rendered in the worksheet table is for reference only and cannot be changed by the end-user.  A simple example might be a Sales Forecast table with columns: Customer, Q1 Forecast Amt, Q1 Actual Amt etc.  In this case, we'd want the end-user to be able to edit the Forecast Amt but not the Customer name.  Since all this data is coming from the external data source, the add-in's java script code would need to be able to write the Customer names into the worksheet.

    Is there a way to make certain cells read-only for the end-user?

    In a VSTO/COM add-in, we could do this by programmatically controlling the worksheet's Protection property (turning it off, writing the company names, then turning it back on).

    Even with the Excel 2016 enhanced APIs available, I don't see a way to achieve this.

    Any suggestions would be appreciated.

    Thanks.


    Shaun Logan - Oracle

    Wednesday, November 4, 2015 8:15 PM

Answers

  • >>>Is there a way to make certain cells read-only for the end-user?

    In a VSTO/COM add-in, we could do this by programmatically controlling the worksheet's Protection

    property (turning it off, writing the company names, then turning it back on). <<<

    As far as I know, there are no protect and up-protect methods in current Office JavaScript API.

    If you have any feedbacks for current Office Development Platform, please feel free to submit them to User Voice.

    http://officespdev.uservoice.com/

    Friday, November 6, 2015 9:12 AM

All replies

  • >>>Is there a way to make certain cells read-only for the end-user?

    In a VSTO/COM add-in, we could do this by programmatically controlling the worksheet's Protection

    property (turning it off, writing the company names, then turning it back on). <<<

    As far as I know, there are no protect and up-protect methods in current Office JavaScript API.

    If you have any feedbacks for current Office Development Platform, please feel free to submit them to User Voice.

    http://officespdev.uservoice.com/

    Friday, November 6, 2015 9:12 AM
  • The question I posed is a general one about making cells read-only.  The example solution I gave from the VSTO add-in environment achieved this by programmatically toggling sheet protection. Your answer confirms that sheet protection toggling is not supported by Office Add-ins.  I guess I can take that to mean that you have no other suggestions for how to achieve read-only cells for an Office Add-in.

    I've logged a UserVoice suggestion:

    https://officespdev.uservoice.com/forums/224641-general/suggestions/10578372-allow-office-add-in-in-excel-to-make-cells-read-on


    Shaun Logan - Oracle

    Wednesday, November 18, 2015 5:07 PM