I have an existing Excel file. I need to programatically password protect the file so that it can't be read unless the user provide the password.
I donot want to use INTEROP object like this
Dim gXL As Excel.Application, gWB As Excel._Workbook, gSheet As Excel._Worksheet ', gRng As Excel.Range ', debug As Boolean = False
Const password As String = "Det gætter I aldrig!"
gXL = New Excel.Application()
Dim templateNAME As String = Server.MapPath(IIf(read_only, "template_readonly.xls", "template.xls"))
gWB = gXL.Workbooks.Open(templateNAME)
gSheet = gWB.ActiveSheet
Dim rest As String = bog(gnames_width) + CStr(gMins.Count + nbr_of_headlines)
gWB.Sheets(2).activate()
gSheet = gWB.ActiveSheet
gSheet.Range("A3", rest).Value2 = gnames
If password <> "" Then gSheet.Protect(password, AllowSorting:=True, AllowFiltering:=True, AllowFormattingColumns:=True).
Please i donot want to use Excel.Application object or interop object.
Suppose my excel sheet is present at C:\temp\cost.xls.
I am generated the excel sheet using XSLT/XML .
Please provide any other way to protect my excel sheet.
Many Thanks.
Bookmarks