示例二
假定表A的结构如下:
希望将其转换为表B,结构为:
转换代码为:
Dim dtb As New
DataTableBuilder("表B")
dtb.AddDef("姓名", Gettype(String), 32)
For Each v As String In DataTables("表A").GetUniqueValues("","课程")
dtb.AddDef(v, Gettype(Double))
Next
dtb.Build()
For Each v As String In DataTables("表A").GetUniqueValues("","姓名")
Dim dr1 As
DataRow = DataTables("表B").AddNew()
dr1("姓名") = v
For
Each dr2 As
DataRow
In
DataTables("表A").DataRows
If dr2("姓名") = v Then
dr1(dr2("课程")) = dr2("分数")
End
If
Next
Next
MainTable = Tables("表B")