如何使用Delphi的readwrite密码创build一个.xls文件

我知道可以使用ADO创build.xls文件,使用Excel创buildOLE自动化,甚至使用多个商业库。

我现在要求的不仅仅是创build一个新的.xls文件并向其中添加数据,而且还要用密码来防止编辑。

我想这将是可能的使用OLE自动化,但这将需要在计算机上的Excel安装,也添加所有我想避免的OLE自动化的潜在麻烦。

其他解决scheme是否提供密码保护文件的选项?

(是的,我知道这是远远不够的,但客户要求,以防万一:我使用delphi2007)

此页面来自NativeExcel Suite:Protect方法的帮助文件

Protects a workbook so that it cannot be modified. Syntax procedure Protect(); procedure Protect( Password : string); Password Optional string. A string that specifies a case-sensitive password for the workbook. If this argument is omitted, you can unprotect the workbook without using a password . Otherwise, you must specify the password to unprotect the workbook. Example This example sets the password for the workbook. workbook.Protect('mypass123'); 

NativeExcel对我来说工作得非常好。