Click here to Skip to main content
12,634,651 members (26,151 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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 20:18pm
ttds874

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161208.2 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2016
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