我正在尝试打开一个 Excel 文件,刷新它后面的查询,然后在 C# 中保存并关闭该文件。
我有以下内容,但首先出现以下行的错误:
object _missingValue = System.Reflection.Missing.Value;
Application excel = new Application();
Workbook theWorkbook = excelFile.Workbooks._Open(txtLocation.Text, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue, _missingValue);
Sheets sheets = (Sheets)theWorkbook.Worksheets;
theWorkbook.RefreshAll();
theWorkbook.Save();
excel.Quit();
我添加了 Microsoft.Office.Interop.Excel 参考,但仍然有问题,我缺少什么?