开发者

How can I create an .xls file with a readwrite password from Delphi

I know that it is possible to create .xls files from Delphi using ADO, OLE automation with Excel and even using several commercial libraries.

My requirement now is not just creating a new .xls file and adding data to it but in addition protecting it with a password against editing.

I guess this would b开发者_运维技巧e possible using OLE automation but that would require an Excel installation on the computer and also add all the potential hassle of OLE automation which I would like to avoid.

Does any of the other solutions provide the option of password protecting the file?

(Yes, I know this is far from secure, but the customer requests it. Just in case it matters: I am using Delphi 2007.)


This page is from the help file from the NativeExcel Suite: Protect method

 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 has worked very well for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜