Summary
This document is designed to provide detailed perspective and presents some material which can measure VSTO (Visual Studio Tools for Office) with its contemporary approaches for developing Microsoft Office based solutions. We compare and contrast VSTO with Aspose.Cells for .NET - a third party .NET component used for spreadsheet management based on some common scenarios & aspects. The article is intended to give the necessary information for making analysis, comparisons and evaluation for adopting any system.
Contents
Here is a quick look what the article is all about:
- Overview
- .NET Framework Requirement
- Features
- Security
- Performance
- System Requirements
- Installation / Deployment
- Conclusion
Overview
While adopting the Office Technology for business implications, we all know the great essence remains in Excel files: the cells are organized in rows and columns into different worksheets, and contain all types of data or formulas with relative or absolute references to other cells. The Intuitive interface related formatting, capable calculation and graphing ability which have made it the dominant spreadsheet in the market today. It not only has editing options, but also possesses the versatility of spreadsheet management. This makes it easier to perform statistical analyses and manipulations on any type of data of any volume.
The Visual Studio Tools for Office (VSTO, also pronounced as “visto”) is a platform that allows Microsoft Office documents to execute code wrapped in a .NET assembly. The technology is used for developing applications based on Microsoft Office. Actually, the developers have been using classic ASP, Office Web components and regular COM Interoperability to build Office based software for years. Microsoft certainly did reshape and enhance VSTO since the introduction of VSTO 2005 and resolved some memory management issues. But, the question is: Is VSTO designed to make development / deployment of such applications easier and more reliable than other approaches available today? Obviously, one should adopt an approach which can be justified fully in terms of improved performance, security, scalability, stability, reliability and features etc.
Aspose - A .NET and Java component publisher provides a great line of .NET and Java components. Trusted by thousands of customers worldwide, the products include File Format Components, Reporting Products, Visual Components and Utility Components. Aspose File Format Components include products such as Aspose.Cells, Aspose.Words, Aspose.Pdf, Aspose.Slides and so on that allow to programmatically open, modify, generate, save, merge, convert documents in various formats including XLS, XLSX, DOC, DOCX, HTML, PDF, PPT and others. In this article, since we compare VSTO with Aspose.Cells for .NET for Excel portion only, so I would like to introduce the component here.
Aspose.Cells is an independent Excel spreadsheet reporting component that enables you to read and write Excel spreadsheets without utilizing Microsoft Excel to be installed either on the client or on the server side. Aspose.Cells is a feature rich component that offers much more than just basic exporting of data. With Aspose.Cells developers can export data, format spreadsheets in every detail and at every level, import images, import create and manipulate charts, stream Excel data, save in various formats (Excel 97 – Excel 2007) including XLS, XLSX, CSV, SpreadsheetML, Tab Delimited, TXT, PDF (Aspose.Pdf integrated) and many more. Aspose.Cells offers an easy to use, feature-rich API for the programmers. It has a huge list of features. To know more about the product, its features, a programmer’s guide and API Reference, please check Aspose.Cells Documentation and online featured Demos. You may download its evaluation version for free.
In this article, we describe some comparison measurements of VSTO and Aspose.Cells on different aspects related to MS Excel. The list is not complete but it represents a few issues that decision makers must understand before making a final decision on adopting the approach.
.NET Framework Requirement
The VSTO does require the .NET framework (including Visual Studio Tools for Office SE Runtime) on the client side to execute the application. In most corporate environments, especially in web scenarios, end-users simply cannot install application software and the related run-time frameworks. This requirement alone puts VSTO-based applications at a serious hindrance. In fact, it practically rules out off-the-shelf applications based on VSTO.
On the contrary, Aspose.Cells for .NET does not necessarily demand .NET framework on the client side for the underlying scenario. The office applications built with the component are light weight and are guaranteed to work on Microsoft Windows systems under significant load.
Features
The features that VSTO provide depend on which combination of Visual Studio Tools for Office and Visual Studio 2005 / 2008 products you have installed. Common tasks performed by VSTO related Microsoft Office Excel 2003 include i.e., Putting data into Worksheet Cells, Creating Workbooks, Opening Workbooks, Saving Workbooks, Adding / Moving / Hiding Worksheets, Protecting Worksheets, Named Ranges, List Object, Styles Formatting, Searching Text in the Worksheet Cells, Sorting Data, Printing and Excel Formula Calculations etc.
Aspose.Cells provides everything needed for managing Office Excel files plus much much more. The component is designed with the philosophy of allowing developers to accomplish the greatest results with the least amount of work. The component provides many powerful, time saving functions. Aspose.Cells supports almost all the features that MS Excel provides. Aspose.Cells provides easy to use APIs for all types of spreadsheet management activities. All the above tasks can be performed by Aspose.Cells APIs but with elegance. Moreover, Aspose.Cells also supports several other advanced features including support for Smart Markers, Importing and Exporting data to and from a number of data sources, objects and Excel files, support for COM clients (ASP client) Interoperability with the component, converting Excel files to Pdf format, making image files from Excel Charts and converting worksheets to image files.
One can try any approach and verify its stability and resource management by performing some of the tasks under heavy load especially on the network environment.
Security
By default, VSTO applications require Full Trust permissions for execution as it does not allow partially trusted callers. Although, to lock down a web application and to provide an additional level of application isolation in a hosted environment, you may use code access security to restrict the resources the application can access and the privileged operations it can perform. But, surely, you do need to invest some time and effort in understanding .NET security.
Mostly, the Internet service providers (ISPs) that need to host multiple applications from many different companies frequently use the medium trust level to help ensure that applications cannot read each other's data or interfere with one another in any way. For security reasons, the ISPs may limit individual web applications on shared servers to Partial Trust.
Aspose.Cells for .NET can run under Medium Trust security level. There are no special privileges that are required to run the assembly in a hosted environment. Medium trust places restrictions on the types of shared system resources that the applications can access. Many web applications are running in Web Hosting servers. In web hosting mode, most of them can only run under Medium Trust security level. Aspose.Cells for .NET can serve their need very well in this regard.
Performance
Performance is the most critical factor when choosing any approach or methodology to build the solution. The performance of a VSTO application, no doubt, does fall back VBA and COM approaches according to some users’ report. There are several factors that influence VSTO performance, and it is important to put these factors in perspective if you intend to draw any meaningful conclusion. The .NET start up cost is inherently expensive. Applications written with .NET must incur the overhead of Just-In-Time (JIT) compilation, so the JIT compilation is a must and cannot be avoided. Another performance factor influencing VSTO-based applications has to do with the expense of calling through the thick layers of automation skin that wrap the Microsoft Office COM objects. VBA, built and optimized to interact with Microsoft Office, has a shorter distance to travel than .NET. Finally, hosting the Excel objects in the Visual Studio IDE is expensive in terms of huge resources. VSTO applications have a larger memory footprint than VBA applications. The VSTO Excel applications eat tons of memory, and never release it back to the OS, until all instances of Microsoft Excel are completely closed. In short, if you are considering adopting VSTO as a development platform for Microsoft Office technology, you should spend some time to understand resources to get familiar with these attributes of this relatively newer technology or otherwise, the investment may go waste.
Moreover, the performance implication of always checking for updates may not be appropriate to the solution (slower deployment servers, slower network connections or simply being unable to reach the server frequently can negatively impact load times).
In contrast, Aspose.Cells for .NET is highly scalable, flexible and fast. Generally, the Office applications were not designed to be simultaneously used by 100s and 1000s of users; however, the component is designed for just to do that. The component is stable and can perform the spreadsheet tasks flawlessly whether on a single server, powering a single application or on a load balanced web farm powering an enterprise wide application.
System Requirements
If we analyze System Requirements for both these approaches, we may easily find that VSTO is more expensive and need more essentials which we have to strictly follow them.
VSTO:
VSTO has a long list of pre-requisites:
- Supported Operating Systems: Windows 2000; Windows Server 2003; Windows Vista; Windows XP
- .NET Framework versions supported: only .NET framework 2.0 or greater.
- One or more of the following editions of Visual Studio Tools for Office:
- Microsoft Visual Studio 2005 Tools for the Microsoft Office System
- Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System
- Visual Studio 2008 Professional Edition
- Visual Studio 2008 Team Suite Edition
- One version of Microsoft Office:
- Microsoft Office Professional 2003 SP1
- 2007 Microsoft Office system
Aspose.Cells for .NET:
Aspose.Cells does not require Microsoft Excel to be installed either on the client or on the server, as Aspose.Cells itself is a spreadsheet creation engine. To view Excel documents, however, produced by Aspose.Cells, you need at least Microsoft Excel Viewer installed on the system.
- Supported Operating Systems: Windows 2000; Windows Server 2003; Windows Vista; Windows XP
- .NET Framework versions supported: all .NET frameworks are supported i.e., 1.0, 1.1, 2.0, 3.x etc.
Installation / Deployment
In some instances, VSTO installations might be a Giant task and can be problematic too. When you run VSTO for the first time, sometimes, a security dialog box appears informing you to explicitly enable access to the Microsoft Office Visual Basic for Applications project. In certain instances, the Microsoft Office Primary Interop Assemblies (PIAs) may fail to install correctly. The solution is to manually re-install the PIAs from the installation media. The Office PIAs are not COM components, so you cannot manually register them at a command prompt using the Windows regsvr32 executable. However, they do incorporate COM Callable Wrappers (CCW) that allow you to call them using a COM interface. To do this, you must register the CCW interfaces using the regasm.exe utility that ships with the .NET framework. In some versions, the application may install without errors but fail to create Excel projects. To solve this problem, make sure that some specific key is accessible in the windows registry. If it is not present, you have to back up the registry and perform some steps in the registry. And, be sure to check the Visual Studio setup log for any installation failures. Issues that arise must be addressed in order for VSTO to function correctly. Moreover, before re-installing Visual Studio.NET to repair broken installations, you must run the vstor.exe (Visual Studio Tools for Office Runtime) application manually.
On the other hand, Aspose.Cells for .NET is packaged into a single DLL, there will never be a need to install any additional parts or pieces related to function it. The component is only utilized by .NET applications and there is no portion of the component code designed to wait on a human response what so ever. You just need to visit Aspose.Cells download page and download the Aspose.Cells.msi installer that contains the latest version of the component (Aspose.Cells.Dll). Just run the downloaded file and follow the installer instructions. To use the component in your project, provide a reference to it and use it with ease.
Performing a Simple Task
Let us perform a simple task using the APIs of both VSTO and Aspose.Cells. We utilize an Excel file (TempBook.xls) as a template. The workbook has some worksheets in it with few cells filled with data.
Task
Fill the template excel file with 1000 * 20 records in its first worksheet. The worksheet is filled with constant (dummy) data into the cells.
Hardware Specifications
The task is performed on a system having Intel(R) Celeron(R) CPU 2.40 GHz, 760 MB of RAM on Microsoft Windows XP Professional operating system.
Code Snippets
We wrote code snippets used by both VSTO and Aspose.Cells with the awareness to accomplish the task. The APIs to perform the task for each approach are parallel and carefully selected to specify the way to obtain the results.
VSTO
……..
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using System.Reflection;
……..
private void button1_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
Excel.Application excelApp = new Excel.ApplicationClass();
string myPath = @"d:\test\TempBook.xls";
excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
for (int i = 1; i <= 1000; i++)
{
for (int j = 1; j <= 20; j++)
{
excelApp.Cells[i, j] = "Row " + i.ToString() + " " + "Col " + j.ToString();
}
}
excelApp.Save(@"d:\test\TempBook1.xls");
excelApp.Quit();
DateTime end = DateTime.Now;
TimeSpan time = end - start;
MessageBox.Show("File Created! " + "Time consumed (Seconds): " + time.TotalSeconds.ToString());
}
Aspose.Cells
……..
using Aspose.Cells;
………
private void button1_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
Workbook workbook = new Workbook();
string myPath = @"d:\test\TempBook.xls";
workbook.Open(myPath);
Worksheet ws = workbook.Worksheets[0];
for (int i = 0; i< 1000; i++)
{
for (int j = 0; j < 20; j++)
{
ws.Cells[i,j].PutValue("Row " + (i+1).ToString() + " " + "Col " + (j+1).ToString());
}
}
workbook.Save(@"d:\test\TempBook1.xls");
DateTime end = DateTime.Now;
TimeSpan time = end - start;
MessageBox.Show("File Created! " + "Time consumed (Seconds): " + time.TotalSeconds.ToString());
}
Results
After performing the above task, the results showed that using VSTO API, it took about 2.5 minutes (approx. over 150 seconds) to finish the task while Aspose.Cells used less than 1 second to complete the similar task on a common hardware with normal system configurations. Even, if I extend the loop i.e. fill (10,000 * 20), Aspose.Cells only takes about 5.5 seconds to do the job. So, apparently, there is no comparison related speed b/w these two approaches.
Conclusion
If you are considering adopting an MS Office technology to your business solutions, it is necessary to become familiar with the choices and alternatives that are available. You should try some tests based on these products and expose them to a variety of real world conditions such as load and stress to see how well they perform before choosing one over another. Aspose.Cells is a stable and mature product with worldwide customer base, and scalable enough to perform well under heavy loads.
The performance of VSTO is not refined yet which certainly does not make it very popular. It is quite possible that some of these performance issues do not relate to VSTO itself rather have connections with .NET JIT compilation processes. But, still, there are certain doubts if the VSTO applications would be scaled themselves as the load increased. Although the newer model of VSTO does not require Excel to be resided on the web server for document processing which might be appealing to some extent but I think VSTO has a long way to go for making the real impact.