照著網上的方法合并excel表中的單元格,參考了Microsoft.Office.Interop.Excel型別庫。

合并的那句話引發了例外。
變數mysheet是從檔案中讀出來的表格,打開監控可以看到下面資訊:

其中的一條資訊如下:
{System.Reflection.TargetInvocationException: 呼叫的目標發生了例外。 ---> System.Runtime.InteropServices.COMException: 格式太舊或是型別庫無效。 (例外來自 HRESULT:0x80028018 (TYPE_E_INVDATAREAD))
--- 內部例外堆疊跟蹤的結尾 ---
在 System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
在 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
在 System.Dynamic.IDispatchComObject.GetMembers(IEnumerable`1 names)}
會是什么原因?我的是excel 2016,會不會是版本原因:用的excel版本高,而參考的那個Microsoft.Office.Interop.Excel類別庫版本低?謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/268642.html
上一篇:如何修改自動雙面列印
