none
How to set password in spreadsheet RRS feed

  • Question

  • I have been successful in setting paassword security on a spreadsheet.  I set a password using excel, then look in the zip file to find the password string that was stored.  Then, I added a protection class to my workbook as follows,, using the password from the zip file.

    SheetProtection sp = new SheetProtection(); sp.Scenarios = true; sp.Objects = true; sp.Sheet = true; sp.Password = "xxxx";
    worksheetPart.Worksheet.Append(sp);

    How do I encrypt a string so that a password can be set?  The documentation does not say what the default encryption method is.  I tried to use MD5, but when I do, it generates an error opening the file.

    dave

    Friday, August 3, 2012 10:28 AM

All replies

  • Hi Dave,

    Thanks for posting in the MSDN Forum.

    As far as I know, that the SheetProtection isn't a build-in class for Excel PIA(primary interop assembly). Would you please clarify this class/interface via a snippet?

    Have a good day,

    Tom


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

    Monday, August 6, 2012 5:02 AM
    Moderator
  • I don't understand. I have given you the snippet of code that I use to set the protection.  As I originally posted, it works if I use a "pre-encoded" password string.  How do I encode the string with my password.

    dave

    Monday, August 6, 2012 2:10 PM
  • Hi Dave,

    Ok, I will involve some experts into your issue. There migth be some time delay, thanks for your patience.

    Have a good day,

    Tom


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

    Tuesday, August 7, 2012 7:57 AM
    Moderator
  • Hello Dave,

    This is actually not the right place for this kind of question. This alias is for developing Excel using VBA. The code snippet you posted is in C or C#. The right alias for that question is the Visual Studio Tools for Office forum: http://social.msdn.microsoft.com/Forums/en-US/vsto/threads

    Will Buffington
    Microsoft Excel Support

    Tuesday, August 7, 2012 7:06 PM
  • I posted this on the Excel for Developers site.  Is this is the wrong spot, is it possible to move it?

    dave

    Tuesday, August 7, 2012 7:13 PM
  • I have just moved the thread to the right spot.
    Tuesday, August 7, 2012 7:15 PM