Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I've a c sharp code where im creating a excel file using openxml and this code runs on a task scheduler every 15 mins to create the excel file. I cant use interop since it wont work with the task scheduler so i have used open xml. This excel file should be in readonly. im NOT able to make this file as read only. i tried protection for workbook and sheets. may be i used it wrong. Can somebody help me, how to make the excel readyonly so that the users cant edit anything?

Thanks in advance.
Posted
Updated 17-Sep-13 9:27am
v3

1 solution

Set ReadOnly attribute using File.SetAttributes Method[^].
 
Share this answer
 
Comments
naveedahmed43 17-Sep-13 16:22pm    
Its not working. I tried like this.
File.setAttributes(Filepath,fileattributes.readonly)..but still its not working. am i doing it correct?

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