Old format or invalid type library 錯誤原因
調用excel方法失敗,Old format or invalid type library
解決方案:
1,這是Excel自身的一個bug,當本地系統環境被設置成非英文的,而Excel是英文的時候,就會出現,需要臨時設定英文環境,代碼如下:
System.Globalization.CultureInfo CurrentCI = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
或者
2,或到“區域與語言選項中”設定當前的區域選項爲當前系統的環境