xlWorkSheet.Cells.Locked = true;
// Locks cells in a excel Sheet
xlWorkSheet.EnableSelection =
Microsoft.Office.Interop.Excel.XlEnableSelection. xlUnlockedCells;
// Restrics selecting to only unlocked cells
xlWorkSheet.Protect("admin",false,true,true,false,false, false,false,false,false,false, false,false,false,false,false) ;
// Protects you Excel sheet with unprotect Password admin and attributes
// similar to Checkboxes as shown in the figure .
Add the above code just before saving your Excel workbook . Now export your excel and try to open it . You will get a message like "Your excel is Protected and readonly . To unlock it blah blah blah .... you will be prompted for password....." .
You might love to read this ? How to remove 'Sys' is undefined ?
Cool na !! For more ASP.NET solutions , Subscribe to my feed or click here to get updates via email
3 comments:
If you're like most modern consumers, you probably can’t afford to spend an entire paycheck on a replica handbags . For high fashion on a budget, turn to Top 1 Handbags. We specialize in meticulous replications of some of the most popular replica louis vuitton , wallets, replica bags , and other accessories. Each replica handbags is meticulously crafted to ensure years of reliable, handsome service.
nice article..Realy helpful
in my web application i need to export data to excel from datatable in a particular format
this has been done
i need to lock some cells range to prevent editing in excel sheet
i tried but it doesnot get locked
ExcApp = New Excel.Application
ExcWS = ExcApp.Worksheets("SHEET1")
ExcWS.Range("A1", "C3").Locked = True
ExcWS.Protect(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
i have above
2) i need to display checkbox against each supplier no displayed in the sheet
& when few of the suppliers are checked , need to import the checked data in the database
Post a Comment