用BDE Table组件怎样把 excel数据导入 dbf 表里去呢? 需要写函数!
解决方案 »
- 能不能查询combobx是否有某个数据集
- 请问高人 这中情况是为什么???
- delphi 判断数据库主键是否重复。id.text,user.text中文提示不能为空
- 如何使用xsl 格式化xml数据?
- DELPHI开发人员指南例子小问题
- 招Delphi高手!
- 李维书中WebService例子,为啥客户端有时报:Invalid Content type text/html,SOAP expect text/xml
- TMTSDataModule 在哪?
- 如何用delphi自带的installshield express制作安装程序?
- 如何在delphi中读取sql数据库中的值?
- delphi不怎么会,求大神救我
- 大家帮我看看,代码出问题了。
SysUtils, Classes, DB,StdCtrls, Graphics, DBTables,BDE,dbierrs,Messages,Windows,Variants,Controls,Dialogs,Comobj,Forms; type
TOpendialogg = class(TOpenDialog)
end;type
TImportTable3 = class(TTable)
private protected public
procedure FromExcel(T : TImportTable3);
published end;procedure Register;implementation procedure TImportTable3.FromExcel(T : TImportTable3);
var
app : Olevariant;
workbook : Olevariant;
opendialog : TOpendialogg;
//stropenfile ,dispstr: String;
// excelvisible : boolean;
rowcount ,columncount: integer;
i,j:integer; begin //excelvisible :=true; opendialog :=TOpendialogg.Create(nil);
opendialog.Filter:='microsoft excel file|*.xls';
opendialog.Execute;
//stropenfile:=opendialog.FileName;
app := createoleobject('excel.application');
workbook:=app.workbooks.open(opendialog.FileName); app.worksheets[1].activate;
//app.visible:=false;
rowcount:=workbook.worksheets[1].UsedRange.Rows.count;
columncount:=workbook.worksheets[1].UsedRange.Columns.count;
t.Insert;
for j:=0 to rowcount-1 do
begin
for i:=0 to columncount-1 do
begin
t.Fields[i].Value:=app.cells[i,j].value;
end;
t.Post;
end;
workbook.close;
app.quit;
app:=unassigned; end;
procedure Register;
begin
RegisterComponents('My five Components', [TImportTable3]);
end;end.
看看从前的帖子
http://bbs.csdn.net/topics/300041106