请问老师们,代码最后,我将Excel保存在桌面,但并不是每台电脑的桌面路径都是一样的,有没有办法可以解决,让这代码适用于每台电脑?
Dim dt As Table = CurrentTable
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As Xls.Style = Book.NewStyle
Style.BackColor = Color.Red
Dim i As Integer = 0
For c As Integer = 0 To dt.Cols.Count -1
If dt.Cols(c).Visible Then
Sheet(0, i).Value = dt.Cols(c).Caption
i = i + 1
End If
Next
i = 1
For r As Integer = dt.TopPosition To dt.BottomPosition
Dim j As Integer = 0
For c As Integer = 0 To dt.Cols.Count -1
If dt.Cols(c).Visible Then
Sheet(i, j).Value = dt.rows(r)(c)
j += 1
End If
Next
i += 1
Next
Book.Save("C:\Users\asus\Desktop\临时\test.xls")
Dim Proc As New Process
Proc.File = "C:\Users\asus\Desktop\临时\test.xls"
Proc.Start()