我在 AsyncFileUpload 的上传完成事件处理程序中有以下代码:
Protected Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AsyncFileUpload1.UploadedComplete
Dim oapp As Excel.Application
Dim oWBa As Excel.Workbook
Dim oWS As Excel.Worksheet
Dim oRng As Excel.Range
oapp = New Excel.Application
AsyncFileUpload1.PostedFile.SaveAs(Server.MapPath("tempfile2.xlsx"))
oWBa = oapp.Workbooks.Open(Server.MapPath("tempfile2.xlsx"))
oWS = DirectCast(oWBa.Worksheets(2),
Excel.Worksheet)
'Here tns is a textbox contained in a panel
tns.Text = Integer.Parse(oWS.Range("W44").Value) + Integer.Parse(oWS.Range("W55").Value)
oWBa.Close()
File.Delete(Server.MapPath("tempfile2.xlsx"))
End Sub
tns 的 autopostback 属性打开了,为什么上传文件时它不改变它的文本?此外,读取 excel 文件的逻辑也没有错误问题,因为我已经使用 VS 2010 和 Uptil 行 tns.text ... 对其进行了调试,我在手表中得到了正确的值。那么我该如何解决呢?