关于excel的编程。200分的报酬!!!(200分)

  • 主题发起人 主题发起人 david_2002
  • 开始时间 开始时间
D

david_2002

Unregistered / Unconfirmed
GUEST, unregistred user!
我用excel对象调用出了excel,但要将excel的窗口控制在一个panel中,
请问大家有什么好办法?
还有,将excel的数据导入至数据库(想access中的导入器那样的),有列程吗?

200分的报酬!!!
 
我在别的地方看到的,可能和你要的不太一样,仅作参考

unit MainForm;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, OleCtnrs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
New1: TMenuItem;
Open1: TMenuItem;
Save1: TMenuItem;
N1: TMenuItem;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
OleContainer1: TOleContainer;
Edit1: TMenuItem;
Cut1: TMenuItem;
Copy1: TMenuItem;
Paste1: TMenuItem;
InsertObject1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
Return1: TMenuItem;
SaveDialog1: TSaveDialog;
procedure New1Click(Sender: TObject);
procedure Open1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Return1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure InsertObject1Click(Sender: TObject);
procedure Cut1Click(Sender: TObject);
procedure Copy1Click(Sender: TObject);
procedure Paste1Click(Sender: TObject);
procedure OleContainer1Activate(Sender: TObject);
procedure OleContainer1Deactivate(Sender: TObject);
private
{ Private declarations }
FFileName: string;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Exit1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.New1Click(Sender: TObject);
begin
OleContainer1.DestroyObject;
end;

procedure TForm1.Open1Click(Sender: TObject);
begin
if OpenDialog1.Execute then begin
FFileName := OpenDialog1.FileName;
OleContainer1.LoadFromFile(FFileName);
end;
end;

procedure TForm1.Save1Click(Sender: TObject);
begin
if FFileName = '' then begin
if SaveDialog1.Execute then
FFileName := SaveDialog1.FileName
else
exit;
end;

OleContainer1.SaveToFile(FFileName);
end;

procedure TForm1.Return1Click(Sender: TObject);
begin
OleContainer1.Close;
end;

procedure TForm1.InsertObject1Click(Sender: TObject);
begin
if OleContainer1.InsertObjectDialog then
OleContainer1.DoVerb(OleContainer1.PrimaryVerb);
end;

procedure TForm1.Cut1Click(Sender: TObject);
begin
OleContainer1.Copy;
OleContainer1.DestroyObject;
end;

procedure TForm1.Copy1Click(Sender: TObject);
begin
OleContainer1.Copy;
end;

procedure TForm1.Paste1Click(Sender: TObject);
begin
if OleContainer1.CanPaste then
OleContainer1.PasteSpecialDialog;
end;

procedure TForm1.OleContainer1Activate(Sender: TObject);
begin
Return1.Enabled := True;
end;

procedure TForm1.OleContainer1Deactivate(Sender: TObject);
begin
Return1.Enabled := False;
end;

end.
 
我找到了个控件,去delphivcl.net download的。smimport135 很不错,我在汉化它,
搞好了,我就传上了给大家.

谢谢lanhuizi,你的答案不是我要的。
 
用panel.Controls[0]定義試試
 
将Excel中的数据导入到数据库中最快的是用ADO方法。你可以先将要导入的Excel打开,
然后从Excel的菜单中选:‘插入——名称——定义’将你要导入的数据全部包括进去,
注意你所定义的第一行系统会自动地作为表的Field,真正的数据将从第二行开始。
给我你的EMAIL,我可以发一个例子给你。
zhouwg@xtnu.edu.cn
 
To Haofei, Pls send me your program ! thanks
yuki_@yeah.net
 
后退
顶部