国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

采用反射實現后期綁定操作EXCEL的簡單代碼(建議加入精華區)

2024-07-21 02:25:21
字體:
來源:轉載
供稿:網友
除了采用tblimp導入excel object庫實現excel的調用外.
其實還可以采用反射的方法獲得屬性,并進行后期綁定實現
excel的調用.下面是簡單的調用excel程序.

using system;
using system.reflection;
using system.windows;
using system.windows.forms;

class testlatebound:system.windows.forms.form
{
    private button mybutton;
    public  testlatebound()
    {
        mybutton=new button();
        mybutton.text="調用excel";
        mybutton.location=new system.drawing.point(100,100);
        mybutton.click+=new system.eventhandler(testbound);
        
        this.controls.add(mybutton);
        this.text="測試后期綁定 excel application";
        
    }
    
    public void testbound(object sender,system.eventargs ef)
    {
        type myexcel;
        myexcel=type.gettypefromprogid("excel.application");   
        
        object objexcel;
        objexcel=activator.createinstance(myexcel);
        
        object[] param=new object[1];
        param[0]=true;
        try
        {
            myexcel.invokemember("visible",bindingflags.setproperty,null,objexcel,param);  //和vc++中差不多,需要將參數封裝為數組傳入
        }
        catch (exception e)
        {
            messagebox.show (e.tostring());
        }

    }
    public static void main()
    {
        application.run(new testlatebound());
    }
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大余县| 犍为县| 历史| 潢川县| 济宁市| 徐水县| 腾冲县| 卢湾区| 彭水| 伊春市| 虞城县| 宾川县| 汝阳县| 宁德市| 海门市| 正蓝旗| 永宁县| 榕江县| 焦作市| 伊宁市| 威海市| 广汉市| 瓦房店市| 延吉市| 丰都县| 凤台县| 林周县| 西昌市| 陵水| 隆子县| 古田县| 锦屏县| 临洮县| 佛冈县| 乌拉特后旗| 临沭县| 淳安县| 淳安县| 星座| 类乌齐县| 青川县|