附件传不了,贴代码:
表A转表B:
DataTables("表B").DataRows.Clear()
For Each adr As DataRow In DataTables("表A").DataRows
If adr.IsNull("姓名") = False Then
For Each adc As DataCol In DataTables("表A").DataCols
If adc.Name.StartsWith("工序") Then
Dim bdr As DataRow = DataTables("表B").AddNew()
bdr("姓名") = adr("姓名")
bdr("工序") = adc.Name
bdr("数量") = adr(adc.Name)
End If
Next
End If
Next
DataTables("表B").Save()
MainTable = Tables("表B")
表B转表A(C):
DataTables("表C").DataRows.Clear()
Dim vals As List(Of String) = DataTables("表B").SQLGetValues("姓名","姓名 Is Not Null")
For Each val As String In vals
Dim ddr As DataRow = DataTables("表C").AddNew()
ddr("姓名") = val
For Each bdr As DataRow In DataTables("表B").DataRows
For Each ddc As DataCol In DataTables("表C").DataCols
If ddc.Name = bdr("工序") AndAlso bdr("姓名") = val Then
ddr(ddc.Name) = bdr("数量")
End If
Next
Next
Next
Tables("表C").Sort = "姓名 Desc"
MainTable = Tables("表C")