Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I don't want to allow edit the excel data after exporting to the excel file. So, How to make a Excel Sheet ReadOnly by C# code ?


thanks,
ttds
Posted

1 solution

You can try one of the following:

  1. Make the file ReadOnly in Windows. This means that the operating system will not allow changes to be made to the file. The user can easily clear the ReadOnly flag, so this is probably not what you want. If you do want to go this route, have a look at File.SetAttributes[^]
  2. Protect the Excel workbook and worksheet with passwords. This means that Excel will not allow changes to be made to the workbook or the worksheet unless the user can provide the correct password. If this is what you want, have a look at Workbook.Protect[^] and Worksheet.Protect[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900