I need to automate a process, for this process I need to open an Excel file that is both Write Protected and Password Protected. When you try to open a file manually it ask for "Password to Open" and "Password to Modify" could you please let me know how to open that type of file using C#?
If you already know the password for that xls file then you may install this Spire.XLS for .NET. It’s an excel component to decrypt xls files using c#. Here’s a sample code below:
[C#]:
Workbook workbook = new Workbook();
workbook.LoadFromFile("test.xls");
Worksheet sheet = workbook.Worksheets[0];
sheet.Unprotect( "password" );
workbook.SaveToFile("result.xls",ExcelVersion.Version97to2003)
I hope this helps.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加