How to Password Protect Excel File But Allow Read-Only?

How to Password Protect Excel File But Allow Read-Only?

I wish to password-protect my Excel file, but allow read-only access to anyone using it. Is this possible? Let me know

Solution:

Yes, you can easily password protect an Excel file and at the same time allow read-only access to others.

Here are the steps to do it:

  1. Open the Excel file that you want to protect.

  2. Click on the 'File' tab in the top left corner of the screen.

  3. Click on 'Save As' and choose the location where you want to save the file.

  4. In the 'Save As' dialog box, click on the 'Tools' button at the bottom and select 'General Options'.

  5. In the 'General Options' dialog box, you will see two password fields. Enter a password in the 'Password to open' field to restrict access to the file. Enter a password in the 'Password to modify' field to restrict editing of the file.

  6. Click 'OK'. You will be prompted to confirm both passwords. Retype the passwords and click 'OK'.

  7. Click 'Save' to save the file with the password protection.

Now, when someone tries to open the file, they will be prompted to enter a password.

They will need to enter the 'Password to open' to view the file and the 'Password to modify' to edit the file. If they don't enter the 'Password to modify', they will be able to open the file in read-only mode.

I hope this helps you achieve password-protected Excel file with read only access.

Note: Be careful with the passwords you choose, as if you forget them, you will not be able to access or edit the file.

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    I'm reading this as "How to password protect excel sheets" (office 2007) - Here's the solution:

    1. Click the Microsoft Office Button (the Round , point to Prepare, and then click Encrypt Document.

    2. In the Encrypt Document dialog box, in the Password box, type a password, and then click OK. You can type up to 255 characters. By default, this feature uses AES 128-bit advanced encryption. Encryption is a standard method used to help make your file more secure.

    3. In the Confirm Password dialog box, in the Reenter password box, type the password again, and then click OK.

    4. To save the password, save the file.
    --------------------------------------------------------

    Making a workbook read only -

    1. On the Review tab, click Protect Document.

    2. Select Restrict Formatting and Editing.

    3. In Formatting restrictions, Editing restrictions and Start enforcement, you can make selections that meet your formatting and editing needs.
    --------------------------------------------------------

    I hope this helps.
  • Mahesh Dahale
    Mahesh Dahale
    For Microsoft Excel 2007

    All About Windows

    I hope this helps.
  • sookie
    sookie
    Thanks for the information both of you. I wish it could work for me but not.

    Well, anyone has any ideas why following properties(or similar to them) exist for net.sf.jasperreports.engine.export.JRPdfExporterParameter Class
    but not for net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter class? Is there any alternative for this? Any other API or similar class providing such properties?

    JRPdfExporterParameter.IS_ENCRYPTED
    JRPdfExporterParameter.IS_128_BIT_KEY
    JRPdfExporterParameter.USER_PASSWORD
    JRPdfExporterParameter.OWNER_PASSWORD

    Why they have provided security related stuff for PDF API but not for Excel ? Any special reason for this ?
    Thanks !
  • sookie
    sookie
    Hi everyone,

    Thanks a lot for the help. Well, my problem is not solved yet and it seem a time-consuming one as many of the Java APIs have taken into consideration of only PDF Files security but not of Excel sheets. Don't know why everyone ignored such thing[I mean excel sheets security]. 😐. Anyway, I found that a password protected excel sheet can be created in Java. See if of any help to anyone here at any point of time.

    Step # 1: Just download latest poi.jar from following location
    #-Link-Snipped-#

    Step # 2: Write a program like following in your machine.
    package demo;
    import java.io.*;
    import org.apache.poi.hssf.usermodel.*;
    /**
     *
     * @author sookie
     */
    public class PasswordProtectedExcelSheet {
     
     
        public static void main(String arg[]) {
            try{
                FileOutputStream out = new FileOutputStream("C:\\Sample.xls");
     
                /* Creates the workbook */
                HSSFWorkbook hssfworkbook = new HSSFWorkbook();
     
              // hssfworkbook.writeProtectWorkbook("xyz","xyz"); --> shows same behaviour even if uncommented
     
                /* Creates a sample sheet with name as Crazyengineer */
                HSSFSheet sheet = hssfworkbook.createSheet("Crazy Engineer");
                String CEAN_NAME = "sookie";
     
               /* Creates first row */
               HSSFRow row = sheet.createRow(0);
     
               /* Creates a first cell */
               HSSFCell cell =row.createCell((short)0);
     
               /* Sets the value in first cell */
               cell.setCellValue(CEAN_NAME);
     
               /* Sets the password for the sheet */
               sheet.protectSheet("xyz");
     
               /* Writes to the File Output stream */
                hssfworkbook.write(out);
                out.close();
            } catch(Exception e){
                e.printStackTrace();
                System.out.println("Exception occured");
            }
        }
     
     
    }
    
    As an outcome of above program, a Sample.xls file will create in C:\ and when you will open it "sookie' will be written in it. The best part is it will not allow you to modify the contents of the cell and would ask to remove the protected fromt he sheet using "Un Protect command" under "Review" tab and when you will remove it, it will ask for the password "xyz'. Afte entering correct password only, it will allow you to modify.

    Worst part is it don't ask for password first. I want that it could first ask for the password without allowing user to view the report file. None of any such methods is provided in the API. I tried almost everything If anyone has any clue or has more time or has interest in playing with the stuff then Please check the classes of poi.jar and see how it can be changed to work in much betre way.

    Any doubts ? Feel free to ask me.

    Thanks !
  • shreya_rulz
    shreya_rulz
    hey heres a much simpler way to do it.
    in your sheet or workbook go to "tools".
    click on "options".
    select the "security " tab out there.
    you have 2 options:first is "password to open" and second is "password to modify".
    select whichever you want.
  • Saandeep Sreerambatla
    Saandeep Sreerambatla
    Moreover , If you want to encrypt and decrypt the file using crytographic methods this is the software.

    Gpg4win

    Will give more details once I work on this.

    for more details check this.

    Gpg4Win




  • sookie
    sookie
    shreya_rulz
    hey heres a much simpler way to do it.
    in your sheet or workbook go to "tools".
    click on "options".
    select the "security " tab out there.
    you have 2 options:first is "password to open" and second is "password to modify".
    select whichever you want.
    Thanks for the information. What if I don't want to do this manually for 1000 of excel sheets ? I just want to automate it in the code? What would be your SIMPLER way then? Any answers?

    English-Scared
    Moreover , If you want to encrypt and decrypt the file using crytographic methods this is the software.

    Gpg4win

    Will give more details once I work on this.

    for more details check this.

    Gpg4Win
    Thanks for the information. What if I don't want to use any third party software?What would be your answer if I want to embed everything in my code only? Any logic you know which these softwares use to encrypt files?

    Before answering again Please read the problem asked carefully.

    Thanks a lot !
  • Aashish Joshi
    Aashish Joshi
    how bout recording a macro for it?? you'll still have to open all the files at least, and set the passwords but you're spared the clicks in between!!
  • sookie
    sookie
    mad_scientist
    you'll still have to open all the files at least, and set the passwords but you're spared the clicks in between!!
    Nope, it will not work in my problem's case. We set passwords through coding and even files also get opened through code only.
  • teddywin125
    teddywin125
    Hello.
    -
    I've met the same problem,and It can be done by the 'Aspose.cells' component.
  • sookie
    sookie
    teddywin125
    Hello.
    -
    I've met the same problem,and It can be done by the 'Aspose.cells' component.
    Hey teddywin, are you saying that by setting "Password" property of "Workbook" Class, it can be done? Can you please put some more light into it like How to go for it ?


    Thanks !
  • M.E. CERVANTES
    M.E. CERVANTES
    sookie
    Hi everyone,
    I found that a password protected excel sheet can be created in Java. See if of any help to anyone here at any point of time.
    Hi Sookie, I found your trend while trying to solve the same problem. You made my day. Thank you.
  • Anoop Kumar
    Anoop Kumar
    Just related to topic:
    Well protecting Excel with password is a myth. anyone can break your password and can able to edit the
    "PASSWORD protected EXCEL SHEET" . just google how to edit password protected excel sheet and you will find the answer. I don't why microsoft added this feature if it is breakable so easily.Funny thing is you will not able to know the password but you after editing you can apply the same password again.😲

You are reading an archived discussion.

Related Posts

Ps. Source: An Email from my friend Once there was a small kid on earth. One fine day she came to know that god is distributing apples to humans in...
Hello CEans, CE's growing bigger & bigger every day. With more number of users, posts & activity, the resources consume lot of money - and leave us a little to...
CEans, If you see anything 'unusual' [Error message, user activity, strange warning message] etc. please immediately inform me at [ admin] at [crazyengineers] dot [com]. Please consider this as my...
Load Runner: LoadRunner is a performance and load testing product by Hewlett-Packard (since it acquired Mercury Interactive in November 2006) for examining system behaviour and performance, while generating actual load....
Hello, Anyone here knows how to change database character encoding. Say I wish to convert any of the current character encoding to UTF-8? Is there a simple method to do...