VSTO



Let us summarize some of the big advantages VSTO has over VBA:

  1. Works with your favorite language: VB, c++et,c .
  2. Uses more powerful forms with expanded potential.
  3. Improves access to data residing on a server (SQL and ADO).
  4. Enhances communication with Web Servers.
  5. Protects users with better security.
  6. Protects code by hiding it from view and preventing inadvertent, inept changes.
  7. Improves the way you deploy new code and future updates to other users.

The code you create for Excel in VSTO is not located inside the document (as it is with VBA), but rather it is a separate DLL file (Dynamic-Link-Library)


These four core objects are:

  1. Excel. Application
  2. Excel. Workbook
  3. Excel. Worksheet
  4. Excel. Range
three Host Controls
  1. NarnedRange is an extension of the Range object
  2. Listobject is a range that extends multiple columns and rows.
  3. Chart is an extension of the Chart object.


Ribbon XML

Defining Callback Methods

Define your callback methods in the Ribbon class in the Ribbon code file. A callback method has several requirements:

  • It must be declared as public.

  • Its name must match the name of a callback method that you assigned to a control in the Ribbon XML file.

  • Its signature must match the signature of a type of callback method that is available for the associated Ribbon control.

Call back method Singature:  http://msdn.microsoft.com/en-us/library/aa722523.aspx

Ribbon tab ControlType: Custom, Office

How to: Change the Position of a Tab on the Ribbon

http://msdn.microsoft.com/en-us/library/bb608600.aspx


Value and Value2

The only difference between the Value and the Value2 property is that the Value2 property doesn't use the Currency and Date data types.

E.g.:

this.Range["A1"].Value2 = DateTime.Now;
this.Range["A2"].Value = DateTime.Now;

=>Result:

41083.94759
23/6/2012 22:44



VSTO.NET addresses the safety and security issues in a couple of ways. Firstly, the new document/view
architecture allows code to be separated from presentation. The code that runs behind the Office document
can have security restrictions applied to it so that it is guaranteed safe and its authenticity can be
verified before being run. Contrast this to the macro approach where embedded macros are permitted to
execute on the user system unbounded.


Primary Interop Assemblies (PIA) are .NET wrappers built around existing COM components that allow
.NET code to communicate with the COM component

Microsoft .NET run-time cannot communicate directly with COM components. When communication
with COM components is required, the .NET Common Language Runtime (CLR) requires an adapter or
proxy to sit between the .NET assembly and the COM component. This adapter translates .NET requests
into COM requests making the automation possible. It’s important to understand that the proxy or
Runtime Callable Wrapper (RCW) does not re-implement functionality in the COM component. It simply
makes the type information inside the COM object available to the calling assembly so communication
or marshalling can take place.


VSTO vs others


VBA:

1. one major drawback was that security was an afterthought in the VBA approach

2.VBA is also a procedural programming language. It cannot take advantage of some of the niceties such
as inheritance, interfaces, and polymorphism.


VBA does provide certain advantages that VSTO cannot provide. For instance, VBA allows code to be
executed in worksheet functions. VSTO is unable to perform this task.


Disadvantages of VSTO

One major drawback to VSTO is that it requires the .NET framework to execute.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值