What you want to do would be possible only if the operating system had some kind of permission that indicated "do not allow copies." However, as far as I know, no operating system (at least Windows, since I assume that this is what is used as the theme, these are C # and Excel files, but I do not exclude it) has this as a specific permission case.
In any case, if there was this option, and the data was set to read-only, someone could read the file in memory, and then output a new file with this specific data. There are more philosophical points about how to prevent copies - it's useless work ( DRM ), but I will just save some time and say that it will be difficult, if not impossible.
However, if you want, you can encrypt the file so that it cannot be used directly in Excel. Then create a kind of wrapper that reads in the encrypted file, decrypts it, and then passes it to Excel. So that someone does not copy the file and does not modify it, you would need to transfer the decrypted data directly to Excel, but I'm not sure if this is possible or not, since I do not have much experience using Excel, not to mention creating applications, who work with him.
If transferring data to Excel does not work, you can try putting the decrypted file in another directory to throw it away, but I doubt it will fool anyone with any quick wits or definition.
If the file in question is supposed to be used directly with Excel (you create Excel files so that someone opens Excel), I would say that it would be impossible to prevent them from changing the file.
source share