Click here to Skip to main content
13,300,331 members (50,789 online)
Rate this:
Please Sign up or sign in to 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 ?

Posted 6-Feb-13 20:18pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100