有没有关于delphi输出到Excel这方面的文章???

解决方案 »

  1.   

    用搜索功能,关键字为excel,会出现一堆
      

  2.   

    procedure TForm1.Button3Click(Sender: TObject);
    var WriteExcel:OLEVariant;
        i,j:integer;
    begin
      WriteExcel:=CreateOLEObject('Excel.Application');
    //  WriteExcel.WorkBooks.Create('d:\ok.xls');
      WriteExcel.WorkBooks.Add();
      WriteExcel.Visible:=True;
      for i:=1 to 3 do
        for j:=1 to 5 do
          begin
            WriteExcel.Cells[i,j].Value:='I='+IntToStr(i)+'J='+IntToStr(j);
          end;
      WriteExcel.ActiveWorkBook.Save;
      WriteExcel.ActiveWorkBook.Close;
      WriteExcel.Quit;
    end;
    ==========
    刚刚速写的,也许对你们有点帮助!((反正运行通过
      

  3.   

    有没有关于OFFICE那几个控件的使用说明?????????
      

  4.   

    陈省的 《delphi深度搜索》 这本书上提了提
    其它的这方面的书面资料比较少
    大部分都是网友们自己整理的,你到论坛上搜搜吧
      

  5.   

    如何在DELPHI中操作EXCEL电子表格
    如何在DELPHI中操作EXCEL电子表格EXCEL电子表格作为办公软件OFFICE中的重要组成部份,是日常办公系统的主要助手,因此许多日常所需的业务方面的数据通常是通过电子表格存取。有时我们需要从日常工作中创建的EXCEL中取得数据进行操作、打印、查询,统计等工作。在这里我将介绍如何利用delphi完成EXCEL电子表格中数据的操作。
    一、新建一项目,从控件栏servers中分别选取控件:excelapplication、excelworkbook1、excelworksheet,放到主窗体from1中,并加入stringgrid、三个按钮、五个显示字段内容的EDIT、二个操作显示记录的label、一个用于打开EXCEL电子表格的控件opendialog等,如下图所示:
     
     
    二、选择excel表'按钮,用于打开EXCEL文件,其代码如下:
    procedure TForm1.Button1Click(Sender: TObject);
    var i,j:integer;
    begin
    opendialog1.InitialDir:=ExtractFileDir(paramstr(0));//文件的打存放初始路径
    opendialog1.Execute;
    Try
    ExcelApplication1.Connect;//EXCEL应用程序
    Except
    MessageDlg('Excel may not be installed',mtError, [mbOk], 0);
    Abort;
    End;
    ExcelApplication1.Visible[0]:=True;
    ExcelApplication1.Caption:='Excel Application';
    try 
    excelapplication1.Workbooks.Open(opendialog1.FileName,
    null,null,null,null,null,null,null,null,null,null,null,null,0);//打开指定的EXCEL 文件
    except
    begin
    ExcelApplication1.Disconnect;//出现异常情况时关闭
    ExcelApplication1.Quit;showmessage('请选择EXCEL电子表格!');
    exit;
    end;
    end;
    ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);//ExcelWorkbook1与Eexcelapplication1建立连接
    ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);//Excelworksheet1与Excelworkbook1建立连接 
    //开始从EXCEL中取数,放到stringgrid1中,取完数后关闭EXCEL
    for i:=1 to 1000 do//最大取值1000
    for j:=1 to 6 do
    begin
    if trim(excelworksheet1.cells.item[i+1,1])<>'' then
    begin
    stringgrid1.rowCount:=i+1;
    stringgrid1.Cells[j,i]:=ExcelWorksheet1.Cells.Item[i+1,j];
    end
    else
    begin
    label3.caption:=inttostr(i-1);
    ExcelApplication1.Disconnect;
    ExcelApplication1.Quit;
    //将第一条数据赋给编辑框
    edit2.text:=stringgrid1.Cells[1,1];
    edit1.text:=stringgrid1.Cells[2,1];
    edit3.text:=stringgrid1.Cells[3,1];
    edit4.text:=stringgrid1.Cells[4,1];
    edit5.text:=stringgrid1.Cells[5,1];
    exit;
    end;
    end;
    end;
    
    三、'下一条记录'按钮,完成记录向下移动,代码如下:
    procedure TForm1.Button2Click(Sender: TObject);
    var x:integer;
    begin
    x:=stringgrid1.row+1;
    if x<> stringgrid1.RowCount then
    begin
    stringgrid1.row:=stringgrid1.row+1;
    label1.caption:=inttostr(x);
    edit2.text:=stringgrid1.Cells[1,x];
    edit1.text:=stringgrid1.Cells[2,x];
    edit3.text:=stringgrid1.Cells[3,x];
    edit4.text:=stringgrid1.Cells[4,x];
    edit5.text:=stringgrid1.Cells[5,x];
    exit;
    end
    else
    showmessage('已到第一条记录!');
    end;
    四、'上一条记录',完成记录上移,代码如下:
    var x:integer;
    begin
    x:=stringgrid1.row-1;
    if x<>0 then
    begin
    stringgrid1.row:=stringgrid1.row-1;
    label1.caption:=inttostr(x);
    edit2.text:=stringgrid1.Cells[1,x];
    edit1.text:=stringgrid1.Cells[2,x];
    edit3.text:=stringgrid1.Cells[3,x];
    edit4.text:=stringgrid1.Cells[4,x];
    edit5.text:=stringgrid1.Cells[5,x];
    exit;
    end
    else
    showmessage('已到最后一条记录!');
    end;
    五、stringgrid中上下移动时代码:
    procedure TForm1.StringGrid1Click(Sender: TObject);
    var i:integer;
    begin
    i:=stringgrid1.Row;
    label1.caption:=inttostr(i);
    edit1.text:=stringgrid1.Cells[2,i];
    edit2.text:=stringgrid1.Cells[1,i];
    edit3.text:=stringgrid1.Cells[3,i];
    edit4.text:=stringgrid1.Cells[4,i];
    edit5.text:=stringgrid1.Cells[5,i];
    end;
    六、运行程序,点击按钮1打开excel表格。程序将启动EXCEL,并打开了选择的电子表格,这时请不要关闭EXCEL,当程序从EXCEL取数完毕将自动关闭EXCEL程序,应用程序取出了EXCEL数据,显示在stringgrid中,并将第一笔数据各字段的值赋给了左边的对应的edit字段。点击按钮2、按钮3可以查看下一条或上一条记录。也可以使用光标在stringgrid1上移动。
     
    同时我们也可以对stringgrid中的记录进行查询、定位。相反,也可以将数据库中的数据输入到EXCEL中。总之,只要我们从EXCEL提取出数据,并保存到stringgrid中,我们就可以进行相应操作,如统计、查询、重新输出,使平进的EXCEL电子表格中的数据在应用程序中得到利用。
      

  6.   

    http://www.delphibbs.com/delphibbs/dispq.asp?lid=759711
      

  7.   

    我有控件
    要不要,能达到目的就行,管它怎么处理
    如果要的话,给邮件给我[email protected]
      

  8.   

    能不能给我发一份,谢谢
    [email protected]
      

  9.   

    多谢这么多热心的朋友啊 ̄ ̄ ̄ ̄ ̄~~~~~~~~~~~~~~~~~~~~``我的信箱是:[email protected]
      

  10.   

    给我发一份,谢谢[email protected]
      

  11.   

    麻烦给我一份,谢谢!
    [email protected]
      

  12.   

    麻烦给我发一份呀!!!感谢
    [email protected]
      

  13.   

    麻煩給我發一份﹐[email protected] 
    也可以直接跟我聯系(加入我的hotmail)
    Thanks
      

  14.   

    http://delphi.ktop.com.tw/forum.asp?FORUM_ID=100
    我找到的一个台湾的网站,讲的很全面,有关于excel和word的,很不错