2010-11-25 25 views
1

SSISを使用してExcelファイルを開き、SQL Serverにデータをインポートする前にデータを更新しようとしています。私のdtsxパッケージは、Excelファイルを開こうとするコード行に失敗しています。SSISを使用してExcelファイルを開くことができません

コードは簡単で、hereから取得しました。

これは私が使用していたコードです:

public void Main() 
{ 
    // TODO: Add your code here 
    Dts.TaskResult = (int)ScriptResults.Success; 

    Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); 
    Microsoft.Office.Interop.Excel.Workbook wb; 

    wb = excel.Workbooks.Open(@"C:\Test.xlsx",0, false, null, null, null, true, null, null, null, null, null, null, null, null); 
    //wb.RefreshAll(); 
    //wb.Save(); 
    //wb.Close(null, null, null); 
    excel.Quit(); 

    System.Runtime.InteropServices.Marshal.ReleaseComObject(excel); 


} 

を次のようにエラーメッセージがある:

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC 
    at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) 
    at ST_2177878595ee4288864728b04a894c16.csproj.ScriptMain.Main() 
    --- End of inner exception stack trace --- 
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) 
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) 
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
    at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) 
    at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() 

私は現在、次のような構成と私のテストマシンに取り組んでいます:

  • Visual Studio 2008 BIDS
  • Office 2010
  • のOffice 2010人のPIA

誰もがこの作業を取得する方法に関して何か提案がありますか?

+0

OSとは何ですか?具体的には、それは32ビットまたは64ビットOSですか? SSISは、64ビットマシンでExcelにアクセスしようとしている場合、32ビットモードで動作するように指示する必要があります。 –

+0

64ビットですが、 "Run64bitRuntime"プロパティはfalseに設定されています。 –

答えて

関連する問題