[分享]直接向excel工作表打印的通用代码: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 '开始填入该列内容
sheet.Cells(r + 5, c + 1).value = tb.Rows(r)(ColNames(c))
Next
Next
app.Visible = True
sheet.PrintPreview()
book.saved=True
book.Close()
app.Quit()
[求助]如何在上面的代码中加入条件:譬如在窗体中加入两个datetimepicker控件
Dim rq_Stat As Date = e.Form.Controls("datetimepicker1").value
Dim rq_End As Date = e.Form.Controls("datetimepicker2").value
进行日期时间条件限制,请高手指导!谢谢!