1
我想打開一個Excel文件,刷新它後面的查詢,然後保存並關閉C#文件。打開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引用,但仍然有問題,我錯過了什麼?
什麼錯誤?他們是否編譯錯誤?還是運行時異常? – psubsee2003
對不起,編譯錯誤 – Stuart1044
認爲我現在明白了: object _missingValue = System.Reflection.Missing.Value; Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); 更改爲上述和錯誤現在消失...這看起來是否正確? – Stuart1044