Click here to Skip to main content
15,846,145 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I've got an xlsx file with charts, tables, formulas. Initially, the file was created in Microsoft Excel 2007.

Is there a way for me to prevent the file from being opened by Microsoft Excel? Maybe by me messing with the file header or maybe me writing a custom wrapper or even custom encrypt it?
After encrypting/wrapping it, the xlsx file should be a file that is not recognized by Microsoft Excel, maybe with a custom extension.

The only way to open the xlsx file is to open it through my C# program, which decrypt or unwrap it and then displaying it also in C# by using DSO framer. The decrypting/unwrapping and displaying it is done without any xlsx file saved on the hard disk.

If there is a way, can somebody please point me to the right direction?
The first phase in my multi-phase program is to encrypt/wrap it (not sure if it is the right terminology or not).
I only know how to describe what I plan to do but don't know what it the right term for it so am not sure how to even start searching for it in google.

Please advise. Thanks.
ZurdoDev 15-Jul-13 10:55am    
Just rename the file so it ends with something custom, like .jojo That will deter most users. Of course you can also password protect it. What are you really trying to accomplish?
Sergey Alexandrovich Kryukov 15-Jul-13 12:14pm    
Exactly. This is the right approach.
JoJo82 15-Jul-13 11:32am    
I have an xlsx file with formulas, graphs, protected information which I do not want my customer to see because those are IP. Lets call it XLSX1.xlsx. Because of that, I want to prevent it from being opened in Microsoft Excel or being opened anywhere. Even if the user were to rename the extension, they still will not be able to open it. That is why I need to encrypt it in such a way that even Excel's password cracker will not be able to crack it.

I have another xlsx file for the customer to enter their information. Lets call it XLSX2.xlsx.
This file, the user can open it normally with Microsoft Excel.

After the user has filled in the information in XLSX2.xlsx, they open my program. My program will decrypt XLSX1.xlsx and load it into filestream, get the necessary formula, do some calculation and then display the result in DSO framer or something. The user will then be able to and save the result in XLSX3.xlsx if they want to.

I hope this paints a much clearer picture of what I plan to do and why.
Sergey Alexandrovich Kryukov 15-Jul-13 12:16pm    
Do what ryanb31 advised. Preventing a real Excel file or a file named like an Excel file from opening by Excel is at least silly.
ZurdoDev 15-Jul-13 12:19pm    
Then don't save in Excel format. Write your own proprietary format in binary.

1 solution

As discussed in comments, I would suggest following the article at[^] to encrypt your file.
Share this answer

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