Excel Events
WorkbookEvents Interface
WorkbookEvents_ActivateEventHandler Delegate
WorkbookEvents_AddinInstallEventHandler Delegate
WorkbookEvents_AddinUninstallEventHandler Delegate
WorkbookEvents_AfterXmlExportEventHandler Delegate
WorkbookEvents_AfterXmlImportEventHandler Delegate
WorkbookEvents_BeforeCloseEventHandler Delegate
WorkbookEvents_BeforePrintEventHandler Delegate
WorkbookEvents_BeforeSaveEventHandler Delegate
WorkbookEvents_BeforeXmlExportEventHandler Delegate
WorkbookEvents_BeforeXmlImportEventHandler Delegate
WorkbookEvents_DeactivateEventHandler Delegate
WorkbookEvents_Event Interface
WorkbookEvents_NewSheetEventHandler Delegate
WorkbookEvents_OpenEventHandler Delegate
WorkbookEvents_PivotTableCloseConnectionEventHandler Delegate
WorkbookEvents_PivotTableOpenConnectionEventHandler Delegate
WorkbookEvents_SheetActivateEventHandler Delegate
WorkbookEvents_SheetBeforeDoubleClickEventHandler Delegate
WorkbookEvents_SheetBeforeRightClickEventHandler Delegate
WorkbookEvents_SheetCalculateEventHandler Delegate
WorkbookEvents_SheetChangeEventHandler Delegate
WorkbookEvents_SheetDeactivateEventHandler Delegate
WorkbookEvents_SheetFollowHyperlinkEventHandler Delegate
WorkbookEvents_SheetPivotTableUpdateEventHandler Delegate
WorkbookEvents_SheetSelectionChangeEventHandler Delegate
WorkbookEvents_SinkHelper Class
WorkbookEvents_SyncEventHandler Delegate
WorkbookEvents_WindowActivateEventHandler Delegate
WorkbookEvents_WindowDeactivateEventHandler Delegate
WorkbookEvents_WindowResizeEventHandler Delegate RefreshEvents Interface
RefreshEvents_AfterRefreshEventHandler Delegate
RefreshEvents_BeforeRefreshEventHandler Delegate
RefreshEvents_Event Interface
RefreshEvents_SinkHelper Class OLEObjectEvents_GotFocusEventHandler Delegate
OLEObjectEvents_LostFocusEventHandler Delegate DocEvents_ActivateEventHandler Delegate
DocEvents_BeforeDoubleClickEventHandler Delegate
DocEvents_BeforeRightClickEventHandler Delegate
DocEvents_CalculateEventHandler Delegate
DocEvents_ChangeEventHandler Delegate
DocEvents_DeactivateEventHandler Delegate
DocEvents_Event Interface
DocEvents_FollowHyperlinkEventHandler Delegate
DocEvents_PivotTableUpdateEventHandler Delegate
DocEvents_SelectionChangeEventHandler Delegate ChartEvents_ActivateEventHandler Delegate
ChartEvents_BeforeDoubleClickEventHandler Delegate
ChartEvents_BeforeRightClickEventHandler Delegate
ChartEvents_CalculateEventHandler Delegate
ChartEvents_DeactivateEventHandler Delegate
ChartEvents_DragOverEventHandler Delegate
ChartEvents_DragPlotEventHandler Delegate
ChartEvents_Event Interface
ChartEvents_MouseDownEventHandler Delegate
ChartEvents_MouseMoveEventHandler Delegate
ChartEvents_MouseUpEventHandler Delegate
ChartEvents_ResizeEventHandler Delegate
ChartEvents_SelectEventHandler Delegate
ChartEvents_SeriesChangeEventHandler Delegate using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection; namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
StartExcelAndSinkEvents();
} //Excel Automation variables:
Excel.Application xlApp;
Excel.Workbook xlBook;
Excel.Worksheet xlSheet1, xlSheet2, xlSheet3;
//Excel event delegate variables:
Excel.AppEvents_WorkbookBeforeCloseEventHandler EventDel_BeforeBookClose;
Excel.DocEvents_ChangeEventHandler EventDel_CellsChange;
Excel.DocEvents_BeforeRightClickEventHandler Event_RightClick;
private void StartExcelAndSinkEvents()
{
//Start Excel, and then create a new workbook.
xlApp = new Excel.Application();
xlBook = xlApp.Workbooks.Open(@"C:\Users\Administrator.PC-20150725BXRI\Desktop\新建 Microsoft Excel 工作表.xlsx");//.Add();
xlBook.Windows.get_Item().Caption = "XL Event Test";
xlSheet1 = (Excel.Worksheet)xlBook.Worksheets.get_Item();
xlSheet2 = (Excel.Worksheet)xlBook.Worksheets.get_Item();
xlSheet3 = (Excel.Worksheet)xlBook.Worksheets.get_Item();
xlSheet1.Activate(); //Add an event handler for the WorkbookBeforeClose Event of the
//Application object.
EventDel_BeforeBookClose = new Excel.AppEvents_WorkbookBeforeCloseEventHandler(BeforeBookClose);
xlApp.WorkbookBeforeClose += EventDel_BeforeBookClose; //Add an event handler for the Change event of both worksheet objects.
EventDel_CellsChange = new Excel.DocEvents_ChangeEventHandler(CellsChange);
xlSheet1.Change += EventDel_CellsChange;
xlSheet2.Change += EventDel_CellsChange;
xlSheet3.Change += EventDel_CellsChange; Event_RightClick = new Excel.DocEvents_BeforeRightClickEventHandler(RightChange);
xlSheet1.BeforeRightClick += Event_RightClick;
xlSheet2.BeforeRightClick += Event_RightClick;
xlSheet3.BeforeRightClick += Event_RightClick; //Make Excel visible and give the user control.
xlApp.Visible = true;
xlApp.UserControl = true;
} private void CellsChange(Excel.Range Target)
{
//This is called when any cell on a worksheet is changed.
MessageBox.Show("Delegate: You Changed Cells " + Target.get_Address(Missing.Value, Missing.Value, Excel.XlReferenceStyle.xlA1, Missing.Value, Missing.Value) + " on " + Target.Worksheet.Name);
} private void RightChange(Excel.Range Target, ref bool bl)
{
MessageBox.Show(bl.ToString() + Target.get_Address());
} private void BeforeBookClose(Excel.Workbook Wb, ref bool Cancel)
{
//This is called when you choose to close the workbook in Excel.
//The event handlers are removed, and then the workbook is closed
//without saving the changes.
Wb.Saved = true; MessageBox.Show("Delegate: Closing the workbook and removing event handlers.");
xlSheet1.Change -= EventDel_CellsChange;
xlSheet2.Change -= EventDel_CellsChange;
xlSheet3.Change -= EventDel_CellsChange;
xlApp.WorkbookBeforeClose -= EventDel_BeforeBookClose;
}
}
}
Excel Events的更多相关文章
- 用laravel Maatwebsite\Excel 教你导出漂亮的Excel表单
先来看效果图 还算是漂亮吧 哈哈哈. 第一步当然是安装包咯 环境要求 PHP: ^7.0Laravel: ^5.5 composer require maatwebsite/excel 目前3.1 只 ...
- VBA 获取Sheet最大行
compared all possibilities with a long test sheet: 0,140625 sec for lastrow = calcws.Cells.Find(&quo ...
- 基于SXSSF (Streaming Usermodel API)的写文件
在POI3.8中SXSSF仅仅支持excel2007格式是对XSSF的一种流的扩展.目的在生成excel时候,需要生成大量的数据的时候,通过刷新的方式将excel内存信息刷新到硬盘的方式,提供写入数据 ...
- POI解决内存溢出问题
在POI3.8中SXSSF仅仅支持excel2007格式是对XSSF的一种流的扩展.目的在生成excel时候,需要生成大量的数据的时候,通过刷新的方式将excel内存信息刷新到硬盘的方式,提供写入数据 ...
- 浅谈Excel开发:五 Excel RTD函数
上文介绍了Excel中的UDF函数,本文介绍一下同样重要的RTD函数.从Excel 2002开始,Excel引入了一种新的查看和更新实时数据的机制,即real-time data简称RTD函数 ...
- Flex导出excel报表
sheetToExcel.java 1 package tree; 2 import java.io.BufferedInputStream; 3 import java.io.File; 4 imp ...
- js 导出Excel
最近从Silverlight这边转到javascript过来,现在要导出一个导出excel的功能.上级领导指示当页显示多少数据,就导出多少数据,没有必要从后台在去数据.以前也没有接触过这方面的,在网上 ...
- [Flex] as3xls读取excel,修改保存单表(二)
这个方法仅用了as3xls读取excel的功能,修改保存独立出来了. <?xml version="1.0" encoding="utf-8"?> ...
- [Flex] as3xls读取excel,修改保存单表(一)
经过大神修改过的as3xls支持中文,并可以修改保存单一sheet,保存后原有的excel样式均会消失,目前仅能如此. <?xml version="1.0" encodin ...
随机推荐
- MVC目录规范
入口程序 单一入口机制,单一入口指在一个web应用程序中,所有的请求都是指向一个脚本文件,例如我们经常看到某一个网站所有的页面都是index.php??xxxx这样的形式.所有对使用程序的访问都是必须 ...
- MySQL修改数据表
ALTER [IGNORE] table tb_name alter_spec,alter_spec......... alter_specification: ADD [COLUMN] create ...
- ambari-server启动出现ERROR main] DBAccessorImpl:106 - Error while creating database accessor java.lang.ClassNotFoundException:com.mysql.jdbc.Driver问题解决办法(图文详解)
不多说,直接上干货! 问题详情 ambari-server启动时,报如下的错误 问题分析 注:启动ambari访问前,请确保mysql驱动已经放置在/usr/share/Java内且名字是mysql- ...
- 案例25-servlet的抽取
1 product模块的抽取版本一 1 ProductServlet代码 抽取之后,原来对应的IndexServlet,ProductListByCidServlet等都可以删除.对应的web.xml ...
- unity Socket TCP连接案例(一)
非常清晰的demo 服务端 using System; using System.Collections; using System.Collections.Generic; using System ...
- hdu 1460 完数
注意:num1和num2的大小未知,需比较! 有两种方法: 法一:素数打印+素数分解(求因数和公式) #include<iostream> #include<cstring> ...
- Tensorflow中的数据对象Dataset
基础概念 在tensorflow的官方文档是这样介绍Dataset数据对象的: Dataset可以用来表示输入管道元素集合(张量的嵌套结构)和"逻辑计划"对这些元素的转换操作.在D ...
- Python基础(3) - 数据类型:2字符串类型
Python字符串的表示有三种方法: 1.单引号(') >>>a = 'I love python. ' 2.双引号(") >>>a = " I ...
- LINQ学习(1)
LINQ LINQ,语言集成查询(Language INtegrated Query)是一组用于C#和Visual Basic语言的扩展.它允许编写C#或者Visual Basic代码以查询数据库相同 ...
- FastReport打印table
经过验证是对的. table第一行添加标题,也就是拖过来的文本label,第二行开始绑定数据源的字段. 先设计报表的静态部分,再用代码注册数据源,然后设计,添加注册的数据源,绑定字段. var rep ...