J
jtoulier
Hello,
I have a problem creating PivotTables in Excel. If we use early binding
we have no problem, but if we use late binding we have the following
problem:
EARLY BINDING (works fine)
**********************************
Workbook oWorkbook;
// oWorkbook is a valid Excel.Workbook
// for example this line works fine
oWorksheet = (Worksheet)oWorkbook.ActiveSheet;
// these lines work fine too !!
PivotCaches oPivotCaches;
oPivotCaches = (Excel.PivotCaches)oWorkbook.PivotCaches();
LATE BINDING (same as above)
*************************************
object oWorkbook;
// oWorkbook is a valid Excel.Workbook
// for example this line works fine
oWorksheet = oWorkbook.GetType().InvokeMember("ActiveSheet",
BindingFlags.GetProperty, null, oWorkbook, null);
// these lines don't work !!
object oPivotCaches;
oPivotCaches = oWorkbook.GetType().InvokeMember("PivotCaches",
BindingFlags.GetProperty, null, moWorkbook, null);
// the error is:
An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an
invocation.
Thanks a lot
Joseph Toulier
I have a problem creating PivotTables in Excel. If we use early binding
we have no problem, but if we use late binding we have the following
problem:
EARLY BINDING (works fine)
**********************************
Workbook oWorkbook;
// oWorkbook is a valid Excel.Workbook
// for example this line works fine
oWorksheet = (Worksheet)oWorkbook.ActiveSheet;
// these lines work fine too !!
PivotCaches oPivotCaches;
oPivotCaches = (Excel.PivotCaches)oWorkbook.PivotCaches();
LATE BINDING (same as above)
*************************************
object oWorkbook;
// oWorkbook is a valid Excel.Workbook
// for example this line works fine
oWorksheet = oWorkbook.GetType().InvokeMember("ActiveSheet",
BindingFlags.GetProperty, null, oWorkbook, null);
// these lines don't work !!
object oPivotCaches;
oPivotCaches = oWorkbook.GetType().InvokeMember("PivotCaches",
BindingFlags.GetProperty, null, moWorkbook, null);
// the error is:
An unhandled exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an
invocation.
Thanks a lot
Joseph Toulier