试试
Dim kxs As List(of String) = DataTables("路缘石检查数据").GetValues("公里桩")
Dim buwei() As String = {"右侧" , "左侧"}
Dim shtrow() As Integer= {7,11,13}
For ix As Integer = 0 To kxs.Count-1
Dim bok As New XLS.Book(ProjectPath & "Attachments\路缘石质量检验评定表_汇总_模板.xlsx")
Dim sht As XLS.Sheet = Bok.Sheets(0)
For bw As Integer = 0 To 1
For Index As Integer = 0 To 2
Dim xcs As List (of DataRow) = DataTables("路缘石检查数据").Select("[工程部位] = '" & buwei(bw) & " 'And [项次] = '" & Index+1 & "' And [公里桩] = '" & kxs(ix) & " ' ")
If xcs.Count > 0 Then
For i0 As Integer = 0 To xcs.Count-1
Dim cov As Double
Double.TryParse(xcs(i0)("数据内容"),cov)
If i0 <= 9 Then
sht(shtrow(Index),8+i0).Value = cov
ElseIf i0 > 9 And i0 <= 19 Then
sht(shtrow(Index)+1,8+(i0-10)).Value = cov
ElseIf i0 > 19 Then
Exit For
End If
Next
sht(3,5).Value = "工程部位:" & buwei(bw)
sht(3,2).Value = kxs(ix)
Bok.Save(ProjectPath & "Reports\LYJC_" & kxs(ix) & "_" & buwei(bw) & ".xlsx")
End If
Next
Next
Next