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

 

    摘要: ◎_◎ ......
 ·这样的sql语句该如何写    »显示摘要«
    摘要: 以下有变量,赋值为temp dim string string=temp table表中有a、b、c、d、e、f、g、h等字段,其中以下字段有值(小写为值) a b c d e f a b c d e;f;g h;i;j 要求从以上字段分别找出是否包含temp, 如果有一个包含就可以。 这样的sql语句如何写呀? sql="select * from table where a=......


报表系统设计中VB与Excel集成应用

报表系统设计中VB与Excel集成应用  
  这是我的毕业设计题目.  
  设计要求:  
  1.要求报表能在事故发生时反映问题所在,因此要求保存前五天的保留虚数据.  
  2.报表数据来源于具体文本方件.  
  3.要求报表数据采用文本方式存储,要将庞大的数据传入OLE容器中的EXCEL工作表,若用简单的循环速度太慢,如何实现数据快速存取也是一个待解决的问题.  
   
  我现在不知道怎么下手,不知那位大虾有这一方面的经验,(最好是能给我个具体的课题,能帮我分析下这个课题)下面是我有的问题,希望知道者能尽快回复我.在此我无比感谢!!!  
  1.报表系统怎么读取五天前的虚数据.  
  2."报表数据来源于具体文本方件"这是什么意思?  
  3."报表数据采用文本方式存储"是不是就用个save   as就可以那.  
  4.在数据存取方面,我想用包传送,可我不知道在VB中怎么实现包传送.  
  (我是个VB新手,我很想通过这课题的设计更好的学习VB,望大家帮忙)    
 

NO.1   作者: netcruiser

给你一个VB输出数据集到EXCEL的例子:  
   
   
    将下文加入到一个模块中,屏幕中调用如下  
  ExporToExcel("select   *   from   table")则实现将其导出到EXCEL中  
   
   
  Public   Function   ExporToExcel(strOpen   As   String)  
  *********************************************************  
  *   名称:ExporToExcel  
  *   功能:导出数据到EXCEL  
  *   用法:ExporToExcel(sql查询字符串)  
  *********************************************************  
  Dim   Rs_Data   As   New   ADODB.Recordset  
  Dim   Irowcount   As   Integer  
  Dim   Icolcount   As   Integer  
   
  Dim   xlApp   As   New   Excel.Application  
  Dim   xlBook   As   Excel.Workbook  
  Dim   xlSheet   As   Excel.Worksheet  
  Dim   xlQuery   As   Excel.QueryTable  
   
  With   Rs_Data  
  If   .State   =   adStateOpen   Then  
  .Close  
  End   If  
  .ActiveConnection   =   Cn  
  .CursorLocation   =   adUseClient  
  .CursorType   =   adOpenStatic  
  .LockType   =   adLockReadOnly  
  .Source   =   strOpen  
  .Open  
  End   With  
  With   Rs_Data  
  If   .RecordCount   <   1   Then  
  MsgBox   ("没有记录!")  
  Exit   Function  
  End   If  
  记录总数  
  Irowcount   =   .RecordCount  
  字段总数  
  Icolcount   =   .Fields.Count  
  End   With  
   
  Set   xlApp   =   CreateObject("Excel.Application")  
  Set   xlBook   =   Nothing  
  Set   xlSheet   =   Nothing  
  Set   xlBook   =   xlApp.Workbooks().Add  
  Set   xlSheet   =   xlBook.Worksheets("sheet1")  
  xlApp.Visible   =   True  
   
  添加查询语句,导入EXCEL数据  
  Set   xlQuery   =   xlSheet.QueryTables.Add(Rs_Data,   xlSheet.Range("a1"))  
   
  With   xlQuery  
  .FieldNames   =   True  
  .RowNumbers   =   False  
  .FillAdjacentFormulas   =   False  
  .PreserveFormatting   =   True  
  .RefreshOnFileOpen   =   False  
  .BackgroundQuery   =   True  
  .RefreshStyle   =   xlInsertDeleteCells  
  .SavePassword   =   True  
  .SaveData   =   True  
  .AdjustColumnWidth   =   True  
  .RefreshPeriod   =   0  
  .PreserveColumnInfo   =   True  
  End   With  
   
  xlQuery.FieldNames   =   True   显示字段名  
  xlQuery.Refresh  
   
  With   xlSheet  
  .Range(.Cells(1,   1),   .Cells(1,   Icolcount)).Font.Name   =   "黑体"  
  设标题为黑体字  
  .Range(.Cells(1,   1),   .Cells(1,   Icolcount)).Font.Bold   =   True  
  标题字体加粗  
  .Range(.Cells(1,   1),   .Cells(Irowcount   +   1,   Icolcount)).Borders.LineStyle   =   xlContinuous  
  设表格边框样式  
  End   With  
   
  With   xlSheet.PageSetup  
  .LeftHeader   =   ""   &   Chr(10)   &   "&""楷体_GB2312,常规""&10公司名称:"     &   Gsmc  
  .CenterHeader   =   "&""楷体_GB2312,常规""公司人员情况表&""宋体,常规"""   &   Chr(10)   &   "&""楷体_GB2312,常规""&10日   期:"  
  .RightHeader   =   ""   &   Chr(10)   &   "&""楷体_GB2312,常规""&10单位:"  
  .LeftFooter   =   "&""楷体_GB2312,常规""&10制表人:"  
  .CenterFooter   =   "&""楷体_GB2312,常规""&10制表日期:"  
  .RightFooter   =   "&""楷体_GB2312,常规""&10第&P页   共&N页"  
  End   With  
   
  xlApp.Application.Visible   =   True  
  Set   xlApp   =   Nothing   "交还控制给Excel  
  Set   xlBook   =   Nothing  
  Set   xlSheet   =   Nothing  
   
  End   Function  
   
   
  注:须在程序中引用Microsoft   Excel   9.0   Object   Library和ADO对象,机器必装Excel   2000  
   
  本程序在Windows   98/2000,VB   6   下运行通过。


 ·网关型与代理型的话题    »显示摘要«
    摘要: 代理型的软件设置复杂,经常出一些希奇古怪的问题,其理念比“相当于直接接入internet”的网关型软件差了一截。但网关型软件的缺点是对客户机的控制较弱。各位大虾有没有两全其美的办法?比如sygate或winroute+某一专门控制客户机的软件? ......
» 本期热门文章:

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