Dim tbl As Table = Tables("表A")
Dim StartDate As Date = tbl.Compute("Min(日期)", "日期 IS NOT NULL")
Dim EndDate As Date = tbl.Compute("Max(日期)", "日期 IS NOT NULL")
Dim dt As Date = StartDate
Dim ss() As String = {"星期天", "星期一", "星期2", "星期3", "星期4", "星期5", "星期6"}
Dim Builder As New DataTableBuilder("统计")
Builder.Adddef("项目", GetType(String), 16)
Do
Dim nm As String = dt.Year & "年_" & dt.Month & "月_" & dt.Day & "_" & ss(dt.DayOfWeek)
Builder.Adddef(nm & "_计划", GetType(Integer))
Builder.Adddef(nm & "_完成", GetType(Integer))
dt = dt.Adddays(1)
If dt > Enddate Then
Exit Do
End If
Loop
Tables("窗口2_Table2").DataSource = Builder.buildDataSource
Dim r As Row
For Each a As String In tbl.DataTable.GetValues("项目")
r = Tables("窗口2_Table2").AddNew
r("项目") = a
For Each dr As DataRow In tbl.DataTable.Select("项目='" & a & "'")
dt = dr("日期")
r(dt.Year & "年_" & dt.Month & "月_" & dt.Day & "_" & ss(dt.DayOfWeek)& "_计划") = dr("计划数")
Next
Next