0

我收到错误:

Microsoft Excel 无法访问文件“..\services\Calculator.xlsx”。有几个可能的原因:
• 文件名或路径不存在。
• 该文件正被另一个程序使用。
• 您尝试保存的工作簿与当前打开的工作簿同名。

有任何想法吗?

我试过了,但似乎不起作用Microsoft Office Excel 无法访问文件 '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
4

1 回答 1

1

我找到了适合我的解决方案。如果您打开组件服务(位于控制面板>管理工具下)计算机>我的电脑>DCom 配置>Microsoft Excel 应用程序,属性,身份选项卡,选择用户。

我创建了一个新的新本地帐户来运行它,一切正常。

于 2013-10-03T12:44:00.057 回答