想不打开execl文件,将foxtable当前表静默地写入指定execl。运行代码时,感到打开了execl,另外黑体部分想换成删除表内所有数据。
请版主指教,谢谢!
Dim dt As Table = CurrentTable '当前表
Dim App As New MSExcel.Application
Dim Wb As MSExcel.Workbook = App.WorkBooks.Open(ProjectPath & "\数据源.xlsm")
Dim Ws As MSExcel.WorkSheet = Wb.worksheets("数据表")
Dim Rg As MSExcel.Range '= Ws.Rows("1:3000") '删除execl表内 Wb.worksheets("数据表")所有数据
Rg = Ws.Cells
Rg.Delete
For c As Integer = 0 To dt.Cols.Count -1 '添加列标题
ws.cells(1,c+1).Value = dt.Cols(c).Name
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To dt.Cols.Count -1
ws.cells(r+2, c+1).Value = dt.rows(r)(c)
Next
Next
app.visible = False
Wb.Save
App.Quit