If MessageBox.Show("是否确认导出?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
Dim gs As String = e.Form.Controls("ComboBox3").value
Dim y As Integer = e.Form.Controls("ComboBox1").value
Dim m As Integer = e.Form.Controls("ComboBox2").value
Dim bk As new XLS.Book
Dim st As XLS.Sheet = bk.Sheets(0)
Tables("工资统计_table1").CreateSheetHeader(st)
For i As Integer = 0 To Tables("工资统计_table1").Rows.Count(True)-1
Dim c As Integer = 0
For j As Integer = 0 To Tables("工资统计_table1").Cols.Count-1
If Tables("工资统计_table1").Cols(j).Visible Then
st(i+2,c).Value = Tables("工资统计_table1").Rows(i,True)(j)
c=c+1
End If
Next
Next
'st(Tables("工资统计_table1").Rows.Count(True)+1,0).Value = "总计"
st.Name = y & "年" & m & "月" & gs & "工资统计"
If not FileSys.DirectoryExists(ProjectPath & "导出数据\工资统计") Then
FileSys.CreateDirectory(ProjectPath & "导出数据\工资统计")
End If
Dim n As Date = Date.Now
Dim s As String = n.Year & "_" & n.Month & "_" & n.Day & "_" & n.Hour & "_" & n.Minute & "_" & n.Second & gs
bk.Save(ProjectPath & "导出数据\工资统计\工资统计" & s & ".xls")
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "导出数据\工资统计\工资统计" & s & ".xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Rg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous '边框线型
Rg.Borders.Weight = MSExcel.XlBorderWeight.xlThin '边框粗细
Rg.Borders.ColorIndex = 0 '边框颜色
Wb.save
App.Visible = True
End If
上面是导出代码