tags:

views:

196

answers:

2

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 be 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.)

A: 

If you can use c#,please check this link:

http://stackoverflow.com/questions/15828/reading-excel-files-from-c

liya
I don't see how anything on that page answers my question. None of the answers contains the words "password" or "protect".
dummzeuch
+1  A: 

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.