是C/S结构的,后台数据库是Oracle8,请在指教!!!急!!
在Delphi5下的编程!
在Delphi5下的编程!
解决方案 »
- 谁能推荐delphi的好书?
- 求教下delphi多线程的初级问题。
- delphi的里的界面里的文字下次起动时会老是变大,为什么呢
- 请高手指教:应用程序退出后,Access数据库报错!
- 请教,如何在DELPHI内增加路由表?替代之前的BAT或DOS命令
- QRDBText1能不能自动压缩文本???
- 为ERP软件添加一付翅膀——增加OLAP(数据仓库之在线分析)功能,提升软件价值
- 请问各位高手,我现在需要通过自己建立RES文件来改变鼠标在FORM上的图标!
- 请问大家我在win98使用dcom时要安装的补丁到哪里下载,服务器和客户端的
- DELPHI安装问题!!!
- 怎么设置DBChart打印预览的边距的初始值????它的默认值上每边15%,如何更改它
- 有关交叉报表的一个小问题.
提供者
Microsoft Jet
All下面
Extended Property 写Excel 8.0
> ExcelApp:=CreateOleObject('Excel.Application');
> MyWorkBook:=CreateOleobject('Excel.Sheet');
> except
> application.Messagebox('?法打?Xls文件,?确?已 ?安?EXCEL.','',
> mb_OK+mb_IconStop);
> Exit;
> end;
> MyworkBook:= ExcelApp.workBooks.Open(opendialog1.FileName);
> //打?文件后,?文件?行操作
> i := 2;
> while true do
> begin
> j:= MyWorkBook.WorkSheets[1].Cells[i,1].Value;
> {上面一行代?就是??元格?行取值}
> try
> tmphykh:=inttostr(j);
> except
> showmessage('can not convert to string, error at the'+inttostr(i)+'line');
> exit;
> end;
> tmpName:= MyWorkBook.WorkSheets[1].Cells[i,2].Value;
> hykhlen:= Length(tmphykh);
> newcardstr:= MyWorkBook.WorkSheets[1].Cells[i,3].Value;
> i := i + 1;
> if (tmpName = '') and (tmphykh = '') then
> break;
> if hykhlen<>0 then
> begin
> if hykhlen <7 then
> begin
> k:=7-hykhlen;
> tmpstr:='';
> for m:=0 to k-1 do
> tmpstr:=tmpstr+'0';
> tmphykh:=tmpstr+tmpHykh;
> end;
> hykhlen:=length(newcardstr);
> if hykhlen <5 then
> begin
> k:=5-hykhlen;
> tmpstr:='';
> for M:=0 to k-1 do
> tmpstr:=tmpstr+'0';
> newcardstr:=tmpstr+newcardstr;
> end;
> with adoquery2 do
> begin
> close;
> SQL.Clear;
> SQL.Add('select id,hykh,[name] from customer where hykh=:hykhvalue');
> Parameters.ParamByName('hykhvalue').Value:= tmphykh;
> Open;
> prior;
> if not eof then
> if trim(tmpName) = trim(FieldByName('Name').AsString) then
> begin
> close;
> SQL.Clear;
> SQL.Add('update customer set newcard='''+newcardstr+''' where hykh=:hykhvalue');
> Parameters.ParamByName('hykhvalue').Value:= tmphykh;
> ExecSQL;
> num:=num+1;
> end; {if}
> end; {with}
> end; {if}
> end; { while}
> ExcelApp:=CreateOleObject('Excel.Application');
> MyWorkBook:=CreateOleobject('Excel.Sheet');
> except
> application.Messagebox('?法打?Xls文件,?确?已 ?安?EXCEL.','',
> mb_OK+mb_IconStop);
> Exit;
> end;
> MyworkBook:= ExcelApp.workBooks.Open(opendialog1.FileName);
> //打?文件后,?文件?行操作
> i := 2;
> while true do
> begin
> j:= MyWorkBook.WorkSheets[1].Cells[i,1].Value;
> {上面一行代?就是??元格?行取值}
> try
> tmphykh:=inttostr(j);
> except
> showmessage('can not convert to string, error at the'+inttostr(i)+'line');
> exit;
> end;
> tmpName:= MyWorkBook.WorkSheets[1].Cells[i,2].Value;
> hykhlen:= Length(tmphykh);
> newcardstr:= MyWorkBook.WorkSheets[1].Cells[i,3].Value;
> i := i + 1;
> if (tmpName = '') and (tmphykh = '') then
> break;
> if hykhlen<>0 then
> begin
> if hykhlen <7 then
> begin
> k:=7-hykhlen;
> tmpstr:='';
> for m:=0 to k-1 do
> tmpstr:=tmpstr+'0';
> tmphykh:=tmpstr+tmpHykh;
> end;
> hykhlen:=length(newcardstr);
> if hykhlen <5 then
> begin
> k:=5-hykhlen;
> tmpstr:='';
> for M:=0 to k-1 do
> tmpstr:=tmpstr+'0';
> newcardstr:=tmpstr+newcardstr;
> end;
> with adoquery2 do
> begin
> close;
> SQL.Clear;
> SQL.Add('select id,hykh,[name] from customer where hykh=:hykhvalue');
> Parameters.ParamByName('hykhvalue').Value:= tmphykh;
> Open;
> prior;
> if not eof then
> if trim(tmpName) = trim(FieldByName('Name').AsString) then
> begin
> close;
> SQL.Clear;
> SQL.Add('update customer set newcard='''+newcardstr+''' where hykh=:hykhvalue');
> Parameters.ParamByName('hykhvalue').Value:= tmphykh;
> ExecSQL;
> num:=num+1;
> end; {if}
> end; {with}
> end; {if}
> end; { while}
var
XlAPP:Variant;
Sheet1:Variant;
i,j:integer;
curRow:integer;
begin
if dbgrid.DataSource.DataSet.RecordCount<1 then exit;
//创建excel对象
try
XlApp:=createoleobject('Excel.Application');
XLApp.Visible:=false;
XLApp.Workbooks.Add(xlWBatWorkSheet);
Sheet1 := XLApp.Workbooks[1].WorkSheets['sheet1'];
// XLApp.Workbooks.Options.CheckSpellingAsYouType:= False;
// XLApp.Workbooks.Options.CheckGrammarAsYouType:= False;
except
showmessage('你的电脑没有安装excel程序,无法完成此功能!');
exit;
end;
curRow:=0;
for j:=0 to dbgrid.FieldCount-1 do
begin
sheet1.cells[1,curRow+1]:=dbgrid.Columns[j].Title.Caption;
inc(curRow);
end;
//处理记录
dbgrid.DataSource.DataSet.First;
i:=2;
while not dbgrid.DataSource.DataSet.Eof do
begin
//处理一行
curRow:=0;
for j:=0 to dbgrid.Columns.Count-1 do
begin
Sheet1.cells[i,curRow+1]:=trim(dbgrid.Fields[j].DisplayText) ;
inc(curRow);
end;
i:=i+1;
dbgrid.DataSource.DataSet.Next;
end;
XLApp.Visible:=true;
end;
http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708
http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708
http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708