• ADO 读写文本文件


        ' 创建配置文件
       
       
        Open ThisWorkbook.Path & "schema.ini" For Append As #1
       
            Print #1, "[table2.csv] "
            Print #1, "Format=CSVDelimited "
            Print #1, "ColNameHeader=False"
            Print #1, "MaxScanRows=0"
            Print #1, "Col1=工号   Text   Width   50  "
            Print #1, "Col2=姓名   Text   Width   50  "
            Print #1, "Col3=入职日期   DateTime"
            Print #1, "Col4=班别   Text   Width   50  "
            Print #1, "Col5=职位   Text   Width   50  "
            Print #1, "Col6=分值补贴   Single"
            Print #1, "Col7=计件分钟   Single"
            Print #1, "col8=上班分钟   Single"
            Print #1, "col9=效率   Single"
            Print #1, " "
            Print #1, "[table1.csv]"
            Print #1, "Format=CSVDelimited  "
            Print #1, "ColNameHeader=False"
            Print #1, "MaxScanRows=0"
            Print #1, "Col1=c1   Text   Width   50  "
            Print #1, "Col2=c2   Text   Width   50  "
            Print #1, "Col3=c3   Text   Width   50  "
            Print #1, "Col4=c4   Text   Width   50  "
            Print #1, "Col5=c5   Text   Width   50  "
            Print #1, "Col6=工号   Text   Width   50  "
            Print #1, "Col7=c7   Text   Width   50  "
            Print #1, "Col8=款号   Text   Width   50  "
            Print #1, "Col9=c9   Text   Width   50  "
            Print #1, "Col10=c10   Text   Width   50  "
            Print #1, "Col11=c11   Text   Width   50  "
            Print #1, "Col12=c12   Text   Width   50  "
            Print #1, "Col13=c13   Text   Width   50  "
            Print #1, "Col14=c14   Text   Width   50  "
            Print #1, "Col15=c15   Text   Width   50  "
            Print #1, "Col16=c16   Text   Width   50  "
            Print #1, "Col17=车种   Text   Width   50  "
          
       
        Close #1


        On Error Resume Next
       
        Dim cnn As New ADODB.Connection
        cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & ";Extended Properties='text;HDR=No;FMT=Fixed';"
       
        If cnn.State = 0 Then
            Set cnn = Nothing
            MsgBox ("数据库连接失败!")
            Exit Sub
        End If
       
        Dim rec As New ADODB.Recordset
       
        rec.Open "select distinct t2.*, (t1.c1 + '-' + t1.c2 + '-1') as 更新时间, t1.款号, t1.车种 from table2.csv as t2" _
            & " left join table1.csv as t1 on t1.工号 = t2.工号" _
            & " order by t2.职位, t2.班别, t2.工号, t1.款号", cnn

  • 相关阅读:
    Linux命令--2
    Linux命令--1
    登陆网页模板
    前端笔记 (2.CSS)
    前端笔记 (1.HTML)
    linux 在执行命令过程中,反单引号(`)这个符号代表的意义为何?
    linux 变量
    Linux文件系统中的inode节点详细介绍
    【Ctrl】 + 【Alt】 + 【F1~F6】 和 【Ctrl】 + 【Alt】 + 【T】打开的终端有什么不同?
    快速建站教程
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4785011.html
Copyright © 2020-2023  润新知