Hallo zusammen,
Vielen Dank für eure Erklärungen. Das eigentliche Problem liegt an der Übergabe einer Zahlen-Reihe an eine Excel-Funktion in IronPython:
Code: Alles auswählen
IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18052 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> from System import Activator, Type
>>> excel = Activator.CreateInstance(Type.GetTypeFromProgID('Excel.Application')
)
>>> wf = excel.WorksheetFunction
>>> data = 1,2,3,4
>>> data
(1, 2, 3, 4)
>>> wf.Median(1,2,3,4)
2.5
>>> wf.Median(data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Could not convert argument 0 for call to Median.
>>> data = str(data)[1:-1]
>>> data
'1, 2, 3, 4'
>>> wf.Median(data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
EnvironmentError: System.Runtime.InteropServices.COMException (0x800A03EC): Die
Median-Eigenschaft des WorksheetFunction-Objektes kann nicht zugeordnet werden.
at Microsoft.Scripting.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32
hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
at CallSite.Target(Closure , CallSite , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site
, T0 arg0, T1 arg1)
at CallSite.Target(Closure , CallSite , Object , Object )
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame
frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0
, T1 arg1, T2 arg2, T3 arg3)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite s
ite, T0 arg0, T1 arg1, T2 arg2)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame
frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0
, T1 arg1, T2 arg2, T3 arg3)
at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedF
rame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 a
rg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.<RunOneInteraction
>b__0()
>>>
Ich sehe das so, dass die Methode Median() ein Problem mit dem Wert von data hat. Nur was? :K
Achso, P.S. Das ist jetzt die Darstellung des urpsrünglichen Problems, "str(data)[1:-1]" würde ich jetzt nicht mehr so verwenden.