还有红色的代码,提示不支持时间格式,想体现date.now怎么办。改为date.today,会出现每次都覆盖。
Dim dt As Table = Tables("BUG录入表")
Dim filepath As String = "C:\BUG录入表\" & Date.Now & ".xls"
Dim nms() As String = {"BUG_ID","测试项目名称","项目简介","测试机型","软件版本","现象描述","怀疑模块","BUG重现类别","严重程度","状态","模块维护人","研发组长","提交人","测试组长","测试提交时间"} '要导出的列名
Dim caps() As String = {"BUG_ID","测试项目名称","项目简介","测试机型","软件版本","现象描述","怀疑模块","BUG重现类别","严重程度","状态","模块维护人","研发组长","提交人","测试组长","测试提交时间"} '对应的列标题
Dim szs() As Integer = {120,300,200,200,200,500,100,100,100,100,100,100,100,100,150} '对应的列宽
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim st As XLS.Style = Book.NewStyle '日期列的显示格式
st.Format = "yyyy-MM-dd"
For c As Integer = 0 To nms.length -1
Sheet(0, c).Value = caps(c) '指定列标题
Sheet.Cols(c).Width = szs(c) '指定列宽
If dt.Cols(nms(c)).IsDate Then '如果是日期列
Sheet.Cols(c).Style = st '设置显示格式
End If
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To nms.length -1
If not dt.rows(r).Isnull(nms(c)) Then Sheet(r +1, c).Value = dt.rows(r)(nms(c))
Next
Next
Book.Save(filepath)
MessageBox.show("保存路径:" & FilePath,"导出成功",MessageBoxButtons.OK,MessageBoxIcon.Information)
DataTables("BUG录入表").load
With DataTables("BUG录入表")
.LoadOver = "BUG_ID"
.LoadReverse=True
.LoadTop = 22
.LoadPage = 0
.Load()
If .TotalPages = 0 Then
.LoadPage = 0
e.Form.Controls("TextBox1").Value = .LoadPage & "/" & .TotalPages
Else
e.Form.Controls("TextBox1").Value = .LoadPage + 1 & "/" & .TotalPages
End If
End With