VB.Net编写单元格奇怪的行为

时间:2019-01-11 00:17:06

标签: excel vb.net

我有一些要写给excel的值,但是没有写。奇怪的是,如果我读取单元格并在MsgBox中显示该值,则会显示该值。因此该值在单元格中,但不是因为它为空。

Dim xlApp As New Application
Dim xlBook As Workbook = xlApp.Workbooks.Add()
Dim xlSheet As Worksheet = CType(xlBook.ActiveSheet, Worksheet)

Dim xlRange As Range = xlSheet.Range("A1")
xlRange.Value = "Starting...."
-----
-----
xlSheet.Range("A3").Value = AuthToken.ToString()
MsgBox("In Cell A3 you have written: " & xlSheet.Range("A3").Value)

Excel

有什么想法吗?

改进

我设法使其正常运行,但是解决方案并不是最佳解决方案,我不想每次都想使用With时使用...

With xlSheet
    Range("A1").Value = "Starting"
    Range("A2").Value = Token
End With

0 个答案:

没有答案
相关问题