如何使用反射在C#中打印Access报告 [英] How to print the Access report in C# using Reflection

查看:85
本文介绍了如何使用反射在C#中打印Access报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用CREATEINSTANCE从VS2010 C#打开MSAccess报告

问题出在docmd.openreport方法中

请帮忙!

I need to open MSAccess report from VS2010 C# using CREATEINSTANCE

The problem is in docmd.openreport method

Please help!!

Type objType = Type.GetTypeFromProgID("Access.Application");
object objAccess = Activator.CreateInstance(objType);

objType.InvokeMember("OpenCurrentDatabase", System.Reflection.BindingFlags.InvokeMethod, null, objAccess, new object[] { strPath });

Object objRptName = sReportName;

objType.InvokeMember("Run", System.Reflection.BindingFlags.InvokeMethod, null, objAccess, new object[] { "ReportTest", "Testing Parameter to be printed on report"});;



在这里需要帮助



Need help here

objType.InvokeMember("OpenReport", System.Reflection.BindingFlags.InvokeMethod, null, objDoCmd, new object[] { 2, moMissing, moMissing })

推荐答案

为什么必须使用Rereflection?更为普遍的方法是使用Office Interops Office主互操作程序集 [ ^ ]
Why must you use Refelection? The more accepted way is to the use the Office Interops Office Primary Interop Assemblies[^]


这篇关于如何使用反射在C#中打印Access报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆