Hello I have a WinForm app that generates a ton of data. Currently I have this savable and open-able in an Excel .xls file format. However I’d like to move away from this so that the user can’t open the file up in Excel and modify the contents freely.
The solution I’ve come up with is encoding this as a new file type, example as an “.por” file. However I also don’t want this to be a simple rename of the extension so that a user could rename back to .xls and being editing. How can I do this?
Furthermore I’m programmitically taking a DataTable and row by row writing this out to the Excel file. Would it help to save the DataTable contents using a different method (not SQL)?
A simple way to do this would be to put your
DataTableinto aDataSet, call theDataSet‘sWriteXml(...)method (which will save your data in XML format to a file) and then encrypt the file usingFile.Encrypt.To read from a file, you reverse the process, using
File.Decryptto turn the file back into a plain-XML file, and then load it into aDataSetusing the DataSet’sReadXml(...)method.