Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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 6-Feb-13 19:18pm
ttds755

1 solution

Rate this: bad
good
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[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
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