Dim rq_Stat As Date = e.Form.Controls("datetimepicker1").value
Dim rq_End As Date = e.Form.Controls("datetimepicker2").value
Dim app As New MSExcel.Application
Dim book As MSExcel.Workbook = app.Workbooks.Open(ProjectPath & "Reports\book1.xls")
Dim sheet As MSExcel.Worksheet = book.Sheets("Sheet2")
Dim tb As Table = Tables("表A")
Dim ColNames As String() = New String(){"列1", "列2", "列3"}
For c As Integer = 0 To ColNames.Length - 1
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
If tb.Cols(ColNames(c)).IsDate Then
If tb.Rows(r)(ColNames(c)) >= rq_start AndAlso tb.Rows(r)(ColNames(c)) <= rq_end Then
sheet.Cells(r + 5, c + 1).value = tb.Rows(r)(ColNames(c))
End If
Else
sheet.Cells(r + 5, c + 1).value = tb.Rows(r)(ColNames(c))
End If
Next
Next
app.Visible = True
sheet.PrintPreview()
book.saved=True
book.Close()
app.Quit()
[此贴子已经被作者于2012-12-28 15:05:54编辑过]