国产探花免费观看_亚洲丰满少妇自慰呻吟_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());
    }
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大理市| 历史| 太和县| 依兰县| 汉沽区| 博野县| 苍南县| 漳州市| 九龙县| 柏乡县| 儋州市| 伽师县| 大同县| 卢氏县| 墨江| 泾源县| 东乡族自治县| 威海市| 洞口县| 连云港市| 灵山县| 通渭县| 新余市| 双辽市| 佳木斯市| 长寿区| 灯塔市| 德保县| 南宁市| 大兴区| 郯城县| 双鸭山市| 郯城县| 建瓯市| 营口市| 临潭县| 梅河口市| 洪雅县| 筠连县| 吴桥县| 仁寿县|