mark 合并模式
Select Case e.Path
Case "test.htm", ""
Dim wb As New WeUI
Dim t As Table = Tables("表a") '表格
Dim cs As String() = {"第一列", "第二列"} '需要合并的列
'设置合并
Dim dic As new Dictionary(of String, Integer)
Dim ls As new List(of String)
For i As Integer = 0 To cs.length-1
Dim top As Integer = 0
For j As Integer = 1 To t.Rows.count-1
Dim r1 As Row = t.Rows(j-1)
Dim r2 As Row = t.Rows(j)
Dim same As Boolean = True
For k As Integer = 0 To i
If r2(cs(k)) = Nothing OrElse r1(cs(k)) <> r2(cs(k)) Then
same = False
Exit For
End If
Next
If same = False Then
If j-Top >= 2 Then
'msgbox(top & "," & i & "," & j-top)
dic.add(top & "," & i, j-top)
For k As Integer = Top+1 To j-1
ls.add(k & "," & i)
Next
End If
Top = j
ElseIf j = t.rows.count-1 Then
If j-Top+1 >= 2 Then
'msgbox(top & "," & i & "," & j-top+1)
dic.add(top & "," & i, j-top+1)
For k As Integer = Top+1 To j
ls.add(k & "," & i)
Next
End If
End If
Next
Next
With wb.AddTable("","Table1")
Dim hrow = .Head.AddRow
For i As Integer = 0 To t.Cols.count-1
hrow.AddCell(t.Cols(i).name)
Next
For r As Integer = 0 To t.Rows.count-1
Dim nrow = .Body.AddRow
For c As Integer = 0 To t.Cols.count-1
Dim str = r & "," & c
If dic.ContainsKey(str) Then
nrow.AddCell(t.Rows(r)(c), "rowspan=" & dic(str))
ElseIf ls.Contains(str) = False Then
nrow.AddCell(t.Rows(r)(c))
End If
Next
Next
End With
e.WriteString(wb.Build)
End Select