如何在delphi中設置鎖定EXCEL表(100分)

  • 主题发起人 主题发起人 fodou
  • 开始时间 开始时间
F

fodou

Unregistered / Unconfirmed
GUEST, unregistred user!
如題<br>我想將導出的Excel表鎖定不能更改,如何操作??
 
Xl.Cells.Select;//Select All Cells <br>Xl.Selection.Locked = True;// Lock Selected Cells <br><br>//Xl:=CreateOleObject('Excel.Application');
 
来自: hsgrass, 时间: 2006/06/16 14:27:54, ID: 3473070 &nbsp;<br>// 详细使用查询VBA手册 <br>unit Unit2; <br><br>interface <br><br>uses <br>&nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, <br>&nbsp;Dialogs, StdCtrls; <br><br>type <br>&nbsp;TForm2 = class(TForm) <br>&nbsp; &nbsp;btn1: TButton; <br>&nbsp; &nbsp;btn2: TButton; <br>&nbsp; &nbsp;procedure btn1Click(Sender: TObject); <br>&nbsp; &nbsp;procedure FormCreate(Sender: TObject); <br>&nbsp; &nbsp;procedure FormDestroy(Sender: TObject); <br>&nbsp;private <br>&nbsp; &nbsp;{ Private declarations } <br>&nbsp;public <br>&nbsp; &nbsp;{ Public declarations } <br>&nbsp;end; <br><br>var <br>&nbsp;Form2: TForm2; <br>&nbsp;excel: Variant; <br>implementation <br><br>uses ComObj; <br><br><br><br>{$R *.dfm} <br><br>procedure TForm2.btn1Click(Sender: TObject); <br>begin <br>excel.Workbooks.add(); <br>excel.visible := true; <br>excel.ActiveSheet.Protect(); <br>end; <br><br>procedure TForm2.FormCreate(Sender: TObject); <br>begin <br>excel := CreateOleObject('Excel.Application'); <br>end; <br><br>procedure TForm2.FormDestroy(Sender: TObject); <br>begin <br>&nbsp;Excel := null; <br>end; <br><br>end. <br>---------------------------------- <br>保护工作表使其不至被修改。
 
接受答案了.
 
后退
顶部