我正在嘗試從使用Excel互操作的電子表格單元格值,但下面的代碼我使用的是產生一個編譯器錯誤:與檢索的單元格值的Excel互操作
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
Range currentFind = sheet.Cells.Find("some string", Type.Missing,
XlFindLookIn.xlValues, XlLookAt.xlPart,
XlSearchOrder.xlByRows, XlSearchDirection.xlNext,
false, Type.Missing, Type.Missing);
if (currentFind[1,1].Value != null)
{
string CellValue = currentFind[1,1].Value.ToString();
}
有什麼想法這裏發生了什麼?我猜猜可能需要施放什麼東西,但我不確定是什麼。我試過鑄造currentFind[1,1].Value
,但這似乎並不奏效。
編輯:
我找到了一個解決辦法,設置Embed Interop Types
到False
上的參考,但我還是想知道是怎麼回事,如何處理這種情況。
你倆所提供的答案回答你的問題還是你去它的底部以不同的方式? – 2013-06-13 10:26:19
@ Andy-對不起,我從來沒有意識到有人回答了這個,因爲我已經知道了。感謝您提供的有用信息! – 2013-06-24 18:55:21