可以生成后,直接设置列背景颜色,如
Dim y1 As String = Date.Now.Year
Dim yf1 As String = Date.Now.Month
Dim yf2 As String = Date.Now.AddMonths(1).Month
Dim y2 As String = Date.Now.AddMonths(1).Year
Dim yf3 As String = Date.Now.AddMonths(2).Month
Dim y3 As String = Date.Now.AddMonths(2).Year
yf1 = yf1.PadLeft(2,"0")
yf2 = yf2.PadLeft(2,"0")
yf3 = yf3.PadLeft(2,"0")
Dim ts1 As Integer = Date.DaysInMonth(y1,yf1)
Dim ts2 As Integer = Date.DaysInMonth(y2,yf2)
Dim ts3 As Integer = Date.DaysInMonth(y3,yf3)
Dim dtb As New DataTableBuilder("lsb")
dtb.AddDef("产品类别", Gettype(String), 30)
dtb.AddDef("产品编码", Gettype(String), 30)
dtb.AddDef("产品名称", Gettype(String), 50)
For i As Integer = 1 To ts1
If i<10
dtb.AddDef(y1 & yf1 & "_0" & i, Gettype(Integer))
Else
dtb.AddDef(y1 & yf1 & "_" & i, Gettype(Integer))
End If
Next
For i As Integer = 1 To ts2
If i<10
dtb.AddDef(y2 & yf2 & "_0" & i, Gettype(Integer))
Else
dtb.AddDef(y2 & yf2 & "_" & i, Gettype(Integer))
End If
Next
For i As Integer = 1 To ts3
If i<10
dtb.AddDef(y3 & yf3 & "_0" & i, Gettype(Integer))
Else
dtb.AddDef(y3 & yf3 & "_" & i, Gettype(Integer))
End If
Next
dtb.Build()
Dim t As Table = Tables("lsb")
For Each c As Col In t.cols
If c.name.contains("_") Then
Dim d As Date = new Date(c.name.SubString(0,4), c.name.substring(4,2), c.name.substring(7,2))
If d < Date.today Then
t.grid.cols(c.name).style.backcolor = color.green
ElseIf d > Date.today.adddays(15) Then
t.grid.cols(c.name).style.backcolor = color.yellow
End If
End If
Next
t.addnew(3)
MainTable = t