How to open an excel file with write protection using C#

Adolfo Sánchez

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#?

N Ali

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.

Reference: https://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Decrypt-Excel-Worksheet-in-C-VB.NET.html

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to turn off write protection in win 7 using diskpart?

分類Dev

How to open a file using Excel VBA and turn off updating links

分類Dev

Write to excel using Apache POI. FileNotFoundException:(The requested operation cannot be performed on a file with a user-mapped section open)

分類Dev

How to write to a file using node

分類Dev

How to open a file using a JButton

分類Dev

How to write a Matlab-struct to an Excel file?

分類Dev

How to open file in C program?

分類Dev

How to remove write protection from a flash drive?

分類Dev

How to append a new row to an Excel file using C# and ClosedXML?

分類Dev

Reading .img file in C using open()

分類Dev

How to write before & after certain substrings in an Open file in python?

分類Dev

Using Open Xml to create xlsx file for Excel 2013

分類Dev

How to create and write to a txt file using VBA

分類Dev

How to write exceptions traceback to a file using python

分類Dev

How can I find a specific data, such as a Date in my Excel file, then write time on the column next to it using VB 6.0?

分類Dev

Python selenium using openpyxl to write result to excel file but there is only case is written to excel file

分類Dev

How to open "PPT file with new" option in Excel VBA

分類Dev

How to write formula dynamically in excel in multiple cells using xlsxwriter module?

分類Dev

Use batchjob to open Excel File

分類Dev

How to insert data from excel file into microsoft localdb database using C#

分類Dev

How to enter a value in a cell based on row-column combination in an Excel .xlsx file using C#?

分類Dev

How to simply keep a file in open status without help of program in C language/etc.. by using windows bare basic features?

分類Dev

Electron - write file before open save dialog

分類Dev

Flask - how to write werkzeug logs to log file using RotatingFileHandler?

分類Dev

How to write integers from file to buffer using POSIX pthreads in Linux?

分類Dev

How to write in ARFF file using LIAC-ARFF package in Python?

分類Dev

How to create a text file and write text character by character using MATLAB?

分類Dev

how to open video file in code blocks using opencv

分類Dev

How to write a script to open a PDF file in Unity when image target is tracked?

Related 関連記事

  1. 1

    How to turn off write protection in win 7 using diskpart?

  2. 2

    How to open a file using Excel VBA and turn off updating links

  3. 3

    Write to excel using Apache POI. FileNotFoundException:(The requested operation cannot be performed on a file with a user-mapped section open)

  4. 4

    How to write to a file using node

  5. 5

    How to open a file using a JButton

  6. 6

    How to write a Matlab-struct to an Excel file?

  7. 7

    How to open file in C program?

  8. 8

    How to remove write protection from a flash drive?

  9. 9

    How to append a new row to an Excel file using C# and ClosedXML?

  10. 10

    Reading .img file in C using open()

  11. 11

    How to write before & after certain substrings in an Open file in python?

  12. 12

    Using Open Xml to create xlsx file for Excel 2013

  13. 13

    How to create and write to a txt file using VBA

  14. 14

    How to write exceptions traceback to a file using python

  15. 15

    How can I find a specific data, such as a Date in my Excel file, then write time on the column next to it using VB 6.0?

  16. 16

    Python selenium using openpyxl to write result to excel file but there is only case is written to excel file

  17. 17

    How to open "PPT file with new" option in Excel VBA

  18. 18

    How to write formula dynamically in excel in multiple cells using xlsxwriter module?

  19. 19

    Use batchjob to open Excel File

  20. 20

    How to insert data from excel file into microsoft localdb database using C#

  21. 21

    How to enter a value in a cell based on row-column combination in an Excel .xlsx file using C#?

  22. 22

    How to simply keep a file in open status without help of program in C language/etc.. by using windows bare basic features?

  23. 23

    Electron - write file before open save dialog

  24. 24

    Flask - how to write werkzeug logs to log file using RotatingFileHandler?

  25. 25

    How to write integers from file to buffer using POSIX pthreads in Linux?

  26. 26

    How to write in ARFF file using LIAC-ARFF package in Python?

  27. 27

    How to create a text file and write text character by character using MATLAB?

  28. 28

    how to open video file in code blocks using opencv

  29. 29

    How to write a script to open a PDF file in Unity when image target is tracked?

ホットタグ

アーカイブ