是C/S结构的,后台数据库是Oracle8,请在指教!!!急!!
在Delphi5下的编程!

解决方案 »

  1.   

    ADOConnection
    提供者
    Microsoft Jet
    All下面
    Extended Property 写Excel 8.0
      

  2.   

    try
    >       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}
      

  3.   

    try
    >       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}
      

  4.   

    procedure DbgridSaveToExcel(dbgrid:TDBgrid);
    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;
      

  5.   

    剽窃了一个帖子内容,应该适合于oracle你看看
    http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708
      

  6.   

    应该对oracle也可以
    http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708
      

  7.   

    应该对oracle也可以
    http://expert.csdn.net/Expert/topic/1973/1973859.xml?temp=.8118708