none
How to protect/share Excel document? RRS feed

  • Question

  • Is it possible to enable "Sharing" on excel documents through OpenXML, or any other library if it can help... I believe this is usually performed when you save the document, but I can't find how to specify saving arguments using this library.

    I'd like to avoid using InterOp since I might batch this process on multiple files through a network.

    EDIT: I found a 2009 post that says Protected workbooks are not supported, but is it also the case for the Sharing options from Excel 2010? http://social.msdn.microsoft.com/Forums/en/oxmlsdk/thread/5d89756c-e097-40d1-9fab-4a36026f6fbc

    Thank you!



    • Edited by muik Tuesday, October 30, 2012 11:07 AM
    Saturday, October 27, 2012 4:10 PM

Answers

All replies

  • Hi muik,

    Thanks for posting in the MSDN Forum.

    I will involve some experts into your issue to see whether they can help you. There might be some time delay, appreciate for your patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 30, 2012 5:30 AM
    Moderator
  • Hello Muik,

    There are two types of protection available in Excel. The first one is protecting the workbook using a password so that it cannot be opened. The second one is protecting the worksheet so that the cells cannot be edited (but the workbook can be opened).

    Using Open XML SDK, you cannot protect the workbook to open. You may use WorkbookProtection class to protect the sheet from getting edited. For more information please refer to the following article:

    http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

    Thanks,

    Sreerenj G Nair

    Tuesday, October 30, 2012 5:28 PM
  • Thank you Sreerenj,

    The link I pasted in my original post was the forum post where I found your link, so I was already aware of this stuff.

    However, what I'm really interested into is to trigger the "Shared" status of a workbook so that multiple users can work in the document simultaneously. Using Excel 2010, you would enable this by going into the "Review" ribbon and click the "Protect and Share workbook". Your link explains how to protect documents, but there's nothing about enabling the shared status.

    How to "Protect and Share" a workbook using OpenXML?

    Tuesday, October 30, 2012 5:36 PM
  • Hi muik

    If all else fails, activate the "Share" option you're interested in in a workbook. Save it. Rename it with the file extension .zip. Now you can inspect the xml files that make up the "package". Somewhere in there you should find the Share information. Knowing in which part (I'd guess the workbook.xml) should lead you to the class in the Open XML SDK that manages this.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, November 1, 2012 5:46 PM
    Moderator
    • Marked as answer by muik Thursday, November 1, 2012 7:09 PM
    Thursday, November 1, 2012 7:09 PM
  • Hello Muik,

    Thank you for sharing the sample code

    Thanks,

    Sreerenj G Nair

    Monday, November 5, 2012 12:11 PM