1、把EXCEL文件导入到ORACLE数据库表中。
2、把ORACLE数据库表中的数据导入到EXCEL文件中。

解决方案 »

  1.   

    ORACLE也是数据库
       倒出——》EXCLE
       转入,我也有一个好例子,比较麻烦,如需要MAIL to me :[email protected]
       程序段:FBOUT 给定一个DBGRID 和要保存的文件名即可,调用的xlsfile,控件可下载或mail
    FUNCTION Fbout(dbgrid:tdbgrid;xfilename:string):BOOLEAN;
     var i,j,x:integer;
        XLSfile: TXLSfile;
       //子过程(针对不同类型的字段分别按不同方式写入)
       procedure addcell(row,col:integer;txt:string;xtype:integer=2);
       var
         SetAtribut:TSetOfAtribut;
        begin
          SetAtribut:=[];
           Include(SetAtribut,acBottomBorder);
           Include(SetAtribut,acTopBorder);
           Include(SetAtribut,acLeftBorder);
           Include(SetAtribut,acRightBorder);
          case xtype  of  //以下判断有助于避免身份证号变成科学记数法的问题
            0:begin
               Include(SetAtribut,acCenter);
               XLSFIle.AddWordCell(col,row,SetAtribut,StrToInt(txt));
              end;
            1:begin
               Include(SetAtribut,acRight);
               XLSFIle.AddDoubleCell(col,row,SetAtribut,StrToFloat(txt));
              end;
            2:begin
               Include(SetAtribut,acLeft);
               XLSFIle.AddStrCell(col,row,SetAtribut,txt);
              end;
          end;
       end;
    begin
    RESULT:=FALSE;
    IF DBGRID.DataSource.DataSet.Active=FALSE THEN  EXIT;
    if xfilename='' then exit;
       XLSfile:=TXLSfile.create(application);
       xlsfile.FileName:=xfilename;
       if copy(xlsfile.FileName,length(xlsfile.FileName)-3,4)<>'.xls' then xlsfile.FileName:=xlsfile.FileName+'.xls';
       xlsfile.clear;
       dbgrid.DataSource.DataSet.First;
       i:=0;
       j:=0;
        for i:=0 to  dbgrid.Columns.Count-1 do
           addcell(j+1,i+1,dbgrid.Columns[i].title.Caption,2);
       j:=j+1;
       while not dbgrid.DataSource.DataSet.Eof do
        begin
          for i:=0 to  dbgrid.Columns.Count-1 do
         if dbgrid.Columns[i].Field.AsString<>'' then
           begin
              if dbgrid.Columns[i].Field.DataType=ftinteger then x:=0 else
              if dbgrid.Columns[i].Field.DataType=ftfloat then x:=1 else
              if dbgrid.Columns[i].Field.DataType=ftword then x:=1 else
              x:=2;
              addcell(j+1,i+1,dbgrid.Columns[i].Field.AsString,x);
           end
           else
              addcell(j+1,i+1,'',2);
         j:=j+1;
         dbgrid.DataSource.DataSet.Next;
       end;
    xlsfile.Write;
    XLSfile.Free;
    RESULT:=TRUE;
    end;