,我發現了錯誤:打開Excel文件的問題
Microsoft Excel cannot access the file '..\services\Calculator.xlsx'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
任何想法?
我想這一點,但似乎並沒有工作Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'
Dim xlApp As Application = New Application
Dim xlWB As Workbook
xlWB = xlApp.Workbooks.Open(Server.MapPath("~") + "\services\Calculator.xlsx", 2, True)
Dim xlSheet As Worksheet = xlWB.Sheets("input output")
xlSheet.Cells(7, 8).value = drpTrades.SelectedValue
xlSheet.Cells(12, 8).value = Convert.ToDecimal(txtIncome.Text)
xlSheet.Cells(9, 8).value = loan.Text
Dim xlRebate As Decimal = xlSheet.Cells(18, 8).value
If xlRebate < 0 Then lblRebate.ForeColor = System.Drawing.Color.Red
lblRebate.Text = "£" + Math.Round(xlRebate, 2).ToString
xlWB.Close(False)
xlApp.Quit()
ReleaseComObject(xlApp)
xlApp = Nothing
嘗試絕對路徑(暫時)。目前的工作目錄更像是一門藝術而不是科學。 – Bathsheba
我有時會遇到讓「Excel」應用程序關閉的問題。在ASP中,這可能會變得很糟糕。獲取服務器並檢查任務管理器以查看它是否正在運行。另外,在那裏,看看你是否可以在登錄到服務器時打開文件。它可能會讓你知道發生了什麼。 – Steve
路徑似乎正確。 Yeap可以打開文件 –