以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  多个数据表结构输出到txt文件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=177691)

--  作者:phoebe-fdk
--  发布时间:2022/5/31 10:48:00
--  多个数据表结构输出到txt文件
Dim Raw As new List(of String)
For Each nd As WinForm.TreeNode In tv.AllNodes
    If nd.Checked = True Then
        Raw.Add(nd.Text)
    End If
Next
If Raw.Count = 0 Then
    messagebox.show("数据表至少选择一个.")
    Return
End If

Dim dt As DataTable
Dim d As Date = Date.Now
Dim Name As String = d.Year & Format(d.Month,"00") & Format(d.Day,"00") & Format(d.Hour,"00") & Format(d.Minute,"00") & Format(d.Second,"00") 
Dim Ex_Path  As String = tb_path & "\\表结构输出_" & name

For Each RawData As String In Raw
    Select Case RawData
        Case "测量信息" 
            dt = DataTables("1")
        Case "原始数据" 
            dt = DataTables("2")
    End Select
    Select Case cb_Format
        Case "TXT"
            Ex_Path = Ex_Path & ".txt" 
            Dim bzf As String = RawData & vbcr & "列名" & vbtab & "类型" & vbtab & "长度"
            FileSys.WriteAllText(Ex_Path ,vbcr & bzf,True,Encoding.Unicode)   \'\'\'写入列名
            For Each dc As DataCol In dt.DataCols
                Dim s As String
                s = dc.Name & vbtab & dc.datatype.Name & vbtab & dc.MaxLength
                FileSys.WriteAllText(Ex_Path ,vbcr & s,True,Encoding.Unicode)   
            Next
Case "Excel"
...
    end select
next

老师,我上面的代码想输出多个数表结构到文本文件或Excel文件中。以上是部分代码,选择了多个数据表,写入到文本文件时,只能写进去一个数据表的结构数据,是哪个地方出错了,Excel可以实现多个数据表结构输出

--  作者:有点蓝
--  发布时间:2022/5/31 10:55:00
--  
调试
msgbox(Raw.count)
For Each RawData As String In Raw
msgbox("RawData=" & RawData)
    Select Case RawData
        Case "测量信息" 
            dt = DataTables("1")
        Case "原始数据" 
            dt = DataTables("2")
    End Select
msgbox("dt=" & dt.name)
msgbox("cb_Format=" & cb_Format)
    Select Case cb_Format
        Case "TXT"
            Ex_Path = Ex_Path & ".txt" 
msgbox("Ex_Path=" & Ex_Path)
            Dim bzf As String = RawData & vbcr & "列名" & vbtab & "类型" & vbtab & "长度"
            FileSys.WriteAllText(Ex_Path ,vbcr & bzf,True,Encoding.Unicode)   \'\'\'写入列名