0

如果我打开我的 web 应用程序文件夹中的一个 excel 工作簿,当我阅读单元格时,它会为我提供我正在处理的以前的 excel 电子表格中的值。这可能是一些缓存问题吗?

    Dim xlApp As Excel.Application = Nothing
    Dim xlWorkBook As Excel.Workbook = Nothing
    Dim xlWorkSheet As Excel.Worksheet = Nothing
    Dim misValue As Object = System.Reflection.Missing.Value
    Dim strCell2 As String = ""
    xlApp = New Excel.ApplicationClass
    xlWorkBook = xlApp.Workbooks.Open("book1.xlsx")
    xlWorkSheet = xlWorkBook.Worksheets("sheet1")
    Dim strOutput As String = ""
    Dim cell As Excel.Range
    Dim i As Integer = 1
    For Each cell In xlWorkSheet.Range("B:B")
        strCell2 = xlWorkSheet.Cells(i, 2).value
        If strCell2 <> Nothing Then
            strCell2 = xlWorkSheet.Cells(i, 2).value ' value here is of a different workbook
            i = i + 1
        Else
            Exit For
        End If
    Next

我可以在我的“解决方案资源管理器”中看到 Excel 电子表格,当我点击它时,它会打开正确的工作簿。困惑的.com。

任何想法,我需要在打开它之前清除内存或缓存吗?

4

0 回答 0