返回首页
当前位置: 主页 > VS2010 >

Visual Studio2010开发office2010办公自动化应用(7)自定义ExcelWorkbook

时间:2010-07-28 22:29来源:blog.csdn.net/yincheng01 作者:admin 点击:

创建后进入VS2010程序界面,在ExcelWorkbookCSDN.xlsx中插入一个webbrower,textbox,button,


双击button,插入下列代码

using System;  
using System.Collections.Generic;  
using System.Data;  
using System.Linq;  
using System.Text;  
using System.Windows.Forms;  
using System.Xml.Linq;  
using Microsoft.Office.Tools.Excel;  
using Microsoft.VisualStudio.Tools.Applications.Runtime;  
using Excel = Microsoft.Office.Interop.Excel;  
using Office = Microsoft.Office.Core;  
using Microsoft.Office.Interop;  
using Microsoft.Office.Core;  
 
namespace ExcelWorkbookCSDN  
{  
    public partial class Sheet1  
    {  
        private void Sheet1_Startup(object sender, System.EventArgs e)  
        {  
            
        }  
 
        private void Sheet1_Shutdown(object sender, System.EventArgs e)  
        {  
        } 
 
        #region VSTO Designer generated code  
 
        /// <summary>  
        /// Required method for Designer support - do not modify  
        /// the contents of this method with the code editor.  
        /// </summary>  
        private void InternalStartup()  
        {  
            this.button1.Click += new System.EventHandler(this.button1_Click);  
            this.Startup += new System.EventHandler(this.Sheet1_Startup);  
            this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);  
 
        } 
 
        #endregion  
 
        private void button1_Click(object sender, EventArgs e)  
        {  
            this.webBrowser1.Navigate(this.textBox1.Text);  
        }  
 
    }  

按下F5开始调试

运行后界面如下,Excel文档打开了以后,文档内嵌一个浏览器


点击登录按钮即可观看想要浏览的网页

 

 

(责任编辑:admin)
[返回顶部]
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名:密码: 验证码:点击我更换图片
推荐内容