zoukankan      html  css  js  c++  java
  • VB 操作Excel总结

    1.将Excel的数据导入数据库

    Dim Conn As ADODB.Connection

    Set Conn = New ADODB.Connection
    Conn.Open "连接到你的数据库XJGL.MDB的字符串"
    Conn.Execute "select * into tmptable from [excel 8.0;database=" + 你的excel表名 + "].[sheet名$]"
    Conn.Execute "insert into xsda(学籍号,准考证号,姓名,性别,出生年月,班级) select 学籍号,准考证号,姓名,性别,出生年月,班级 from tmptable"
    Conn.Execute "drop tabel tmptable"
    Set Conn = Nothing

    2.读写Excel文件

        Dim xlApp As Object
        Dim xlBook As Object
        Dim xlSheet As Object
        On Error Resume Next
       
        Set xlApp = CreateObject("Excel.Application")
        Set xlBook = xlApp.Workbooks.Open(App.Path & "\test.xls")
        Set xlSheet = xlBook.Worksheets(1)
       
        xlApp.Visible = False
        xlSheet.Activate
       
        '处理数据,填充Excel表
        xlSheet.Cells(3, 4) = "test"
       
        xlApp.Visible = True '显示Excel
       
        Set xlApp = Nothing '交还控制给Excel
        Set xlBoook = Nothing
        Set xlSheet = Nothing
  • 相关阅读:
    react创建项目01
    jq中的时间转化
    vue-resource调用promise取数据方式整理
    ES6 语法
    js获取时间
    trigger()模拟事件操作
    移动端调出不同需求的键盘
    移动端ios滚动卡顿问题
    godaddy购买的域名解析到aws的route53
    k8s 排错
  • 原文地址:https://www.cnblogs.com/niceboy/p/859227.html
Copyright © 2011-2022 走看看