当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·来看看吧,很容易拿的分    »显示摘要«
    摘要: 介绍几个好的php的网站吧 ......
    摘要: 誰可以給我發個itextasian.jar文件,我在http://www.lowagie.com上下載不了,我的mail:zxqhf@163.com ......


如何将dbgrid的查询内容保存为 excel文件

数据库格式为   paradox  
  查询结果显示在dbgrid  
  怎样将其保存为   excel   文件

NO.1   作者: rlongriver

供参考:  
   
  //输出到   Excel   文件  
  procedure   OutputExcel(ExcelApplication:   TExcelApplication;DataSet:   TQuery;Flag:   integer);  
  var  
      Sheet1   :   OleVariant;           //   Excel文件中的一页  
      j   :   integer;                           //循环控制表量  
      FieldNum:   integer;               //字段个数  
  begin  
      Sheet1   :=   ExcelApplication.Workbooks[1].Sheets[1];  
      Sheet1.visible   :=   true;  
      if   Flag   =   0   then  
      begin  
          FieldNum   :=   DataSet.FieldCount   -1;  
      end  
      else  
      begin  
          FieldNum   :=   DataSet.FieldCount   -3;  
      end;  
      for   j   :=   0   to   FieldNum   do     //   输出标题  
      begin  
          Sheet1.Cells[CellRow,CellCol   +   j]   :=     +   DataSet.Fields[j].DisplayLabel;  
          Sheet1.Cells[cellrow,CellCol   +   j].Font.Name   :=   宋体;  
          Sheet1.Cells[cellrow,CellCol   +   j].Font.Size   :=   12;  
          Sheet1.Cells[cellrow,CellCol   +   j].Font.Bold   :=   True;  
      end;  
      DataSet.First;  
      while   not   DataSet.Eof   do             //   输出内容  
      begin  
          Inc(CellRow);  
          for   j   :=   0   to   FieldNum   do  
          begin  
              Sheet1.Cells[Cellrow,CellCol+j].Font.Name   :=   宋体;  
              Sheet1.Cells[cellrow,CellCol+j].Font.Size   :=   9;  
              Sheet1.Cells[CellRow,CellCol+j]   :=     +   DataSet.Fields[j].AsString;  
          end;  
          DataSet.Next;  
      end;  
  end;  
  //关闭EXCEL  
  procedure   CloseExcel(ExcelApplication   :   TExcelApplication);  
  begin  
      ExcelApplication.Quit;  
      ExcelApplication.Disconnect;  
  end;


 ·为何多了上下一截到屏幕外了    »显示摘要«
    摘要: 让窗体自动适应桌面大小 为何多了上下一截到屏幕外了 procedure tform_main.autoadaptform(sender: tobject) ; var lprect:trect; begin systemparametersinfo(spi_getworkarea,0,@lprect,0); form_main.left := lprect.left; form_main.......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE