当前位置:首页 » 软件行业

什么控件能打开二进制的 xls 文件? Spreadsheet 能实现吗?

八月 3, 2007

 发表在: java



如题,帮帮忙!谢谢!

电脑软件技术推荐:

  • 在ASP中用“VBScript5”编写COM组件[详细内容]
  • 编写Enterprise bean的客户端(下)[详细内容]
  • 编写Enterprise bean的客户端(上)[详细内容]
  • 用VB编写标准CGI程序(下)[详细内容]
  • 用ASP编写图片计数器[详细内容]
  • 罗大佑与三万歌迷共同放歌深圳[详细内容]
  • 深圳[详细内容]
  • 深圳[详细内容]
  • QDI华东、西南经销商聚首深圳[详细内容]
  • 年产千万台的CDMA手机生产基地落户深圳[详细内容]
  • 相关提议:
    发表者:pweixing

    vb工程里面引用excel以后,很多控件都可以打开,mshflexgrid1   都可以从excel中读入然后按单元格写入。

    发表者:crycoming

     
      用vb控制excel生成报表    
      做为一种简捷、系统的   windows应用程序开发工具,visual   basic   5   具有强大的数据处理功能,提供了多种数据访问方法,可以方便地存取microsoft   sql   server、oracle、xbase等多种数据库,被广泛应用于建立各种信息管理系统。但是,vb缺乏足够的、符合中文习惯的数据表格输出功能,虽然使用crystal   report控件及   crystal   reports程序可以输出报表,但操作起来很麻烦,中文处理能力也不理想。excel作为micorsoft公司的表格处理软件在表格方面有着强大的功能,我们可用vb5编写直接控制excel操作的程序,方法是用vb的ole自动化技术获取excel   97   的控制句柄,从而直接控制excel   97的一系列操作。  
       
      下面给出一个实例:  
       
      首先建立一个窗体在窗体中加入一个data控件和一按钮,  
       
      引用microsoft   excel类型库:  
       
      从"工程"菜单中选择"引用"栏;  
       
      选择microsoft   excel   8.0   object   library;  
       
      选择"确定"。  
       
      在form的load事件中加入:  
        data1.databasename   =   数据库名称  
        data1.recordsource   =   表名  
        data1.refresh  
       
      在按钮的click事件中加入  
        dim   irow,   icol   as   integer  
        dim   irowcount,   icolcount   as   integer  
        dim   fieldlen()   "存字段长度值  
        dim   xlapp   as   excel.application  
        dim   xlbook   as   excel.workbook  
        dim   xlsheet   as   excel.worksheet  
       
        set   xlapp   =   createobject("excel.application")  
        set   xlbook   =   xlapp.workbooks.add  
        set   xlsheet   =   xlbook.worksheets(1)  
       
        with   data1.recordset  
        .movelast  
       
        if   .recordcount   <   1   then  
          msgbox   ("error   没有记录!")  
          exit   sub  
        end   if  
       
        irowcount   =   .recordcount   "记录总数  
        icolcount   =   .fields.count   "字段总数  
       
        redim   fieldlen(icolcount)  
        .movefirst  
       
      8  
       
        for   irow   =   1   to   irowcount   +   1  
         for   icol   =   1   to   icolcount  
        select   case   irow  
        case   1   "在excel中的第一行加标题  
        xlsheet.cells(irow,   icol).value   =   .fields(icol   -   1).name  
        case   2   "将数组fieldlen()存为第一条记录的字段长  
       
        if   isnull(.fields(icol   -   1))   =   true   then  
          fieldlen(icol)   =   lenb(.fields(icol   -   1).name)  
           "如果字段值为null,则将数组filelen(icol)的值设为标题名的宽度  
        else  
          fieldlen(icol)   =   lenb(.fields(icol   -   1))  
        end   if  
       
        xlsheet.columns(icol).columnwidth   =   fieldlen(icol)  
         "excel列宽等于字段长  
        xlsheet.cells(irow,   icol).value   =   .fields(icol   -   1)  
         "向excel的cells中写入字段值  
        case   else  
        fieldlen1   =   lenb(.fields(icol   -   1))  
       
        if   fieldlen(icol)   <   fieldlen1   then  
        xlsheet.columns(icol).columnwidth   =   fieldlen1  
         "表格列宽等于较长字段长  
        fieldlen(icol)   =   fieldlen1  
         "数组fieldlen(icol)中存放最大字段长度值  
        else  
         xlsheet.columns(icol).columnwidth   =   fieldlen(icol)  
        end   if  
       
        xlsheet.cells(irow,   icol).value   =   .fields(icol   -   1)  
        end   select  
        next  
        if   irow   <>   1   then  
        if   not   .eof   then   .movenext  
        end   if  
        next  
        with   xlsheet  
        .range(.cells(1,   1),   .cells(1,   icol   -   1)).font.name   =   "黑体"  
         "设标题为黑体字  
        .range(.cells(1,   1),   .cells(1,   icol   -   1)).font.bold   =   true  
         "标题字体加粗  
        .range(.cells(1,   1),   .cells(irow,   icol   -   1)).borders.linestyle   =   xlcontinuous  
         "设表格边框样式  
        end   with  
        xlapp.visible   =   true   "显示表格  
        xlbook.save   "保存  
        set   xlapp   =   nothing   "交还控制给excel  
        end   with  
       
      本程序在中文windows98、中文vb5下通过。    
       
         
       
     

    发表者:daisy8675

    spread   安装以后,本身带有exp  
       
      你可以打开看看它的范例就会知道答案了.  
       
     

    .

    No comments in this entry


    Post a Comment »

    Logged in

    Advertising

    Categories

    相关文章