导出excel 表代码如下:
此主题相关图片如下:2556b5e7599de0c1d17f45e46fbe83d.jpg
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "EXCEL 文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
' MessageBox.Show("你要保存为:" & dlg.FileName,"提示") '提示用户选择的文件
' Dim ex As New Exporter
' ex.FilePath = dlg.FileName '指定目标文件
Dim tb As Table
Dim Book As New XLS.Book() '(dlg.FileName)
' MessageBox.Show("dim book")
Dim s As Integer =1
For Each tb In Tables
If tb.name.Contains(".") Then
Else
book.Sheets.Add(tb.name)
' MessageBox.Show(tb.name)
For c As Integer = 0 To tb.Cols.Count -1 '添加列标题
book.Sheets(tb.name)(0, c).Value = tb.Cols(c).Name
Next
For r As Integer = 0 To tb.Rows.Count - 1 '填入数据
For c As Integer = 0 To tb.Cols.Count -1
book.Sheets(tb.name)(r +1, c).Value = tb.rows(r)(c)
Next
Next
End If
Next
'打开工作簿
'MessageBox.Show("add")
Book.Save(dlg.FileName)
Dim Proc As New Process
Proc.File = dlg.FileName
Proc.Start()
End If