preface

I like to consider another question before answering: is it a reasonable question? But the student who asked the question may not think so. Maybe they’ve been so pressured by the project that they don’t want to think about it, they just want a simple answer. This process was a pain in the ass because I had to spend extra energy thinking about the motivation and context of the question, but the questioner was often ungrateful and our conversation was often not on the same channel.

A typical example is Office OLE automation (mostly Excel). When faced with such a problem, I would simply recommend abandoning the project. As for the responses from the questioners, they were all over the place, mostly polite, but I could hear the underlying message: Don’t bother answering if you don’t want to. In such cases, I usually choose silence, because it is difficult to make myself clear in one or two sentences. But now that I have my own blog, I’ll take the time to explain my thoughts.

My experience in project development has taught me that Office automation is fundamentally wrong and can lead to a series of bizarre problems that can give you headaches. Choosing the wrong solution and then trying to solve all sorts of weird problems is, to put it bluntly, like trying to put on makeup after a sore, which doesn’t help but leaves more problems for whoever takes over later. Why not end the problem in your own hands?

Some people replied that the project has been made like this, there is no way, it is impossible to change. I sympathize with the helpless and miserable coder, but disagree with this conclusion. In my experience developing systems, working with Office files is a relatively independent, easy part to package and test. If you don’t have the guts to refactor that feature, I can’t imagine how confident you’ll be in changing code for a more complex business. Taking on a project that you don’t have the courage to change is unfortunate for both you and the company. If you are really sure that you do not have the ability to change, I suggest you resign as soon as possible, responsible for the company and also responsible for yourself; If your company won’t allow you to make changes, I suggest you send them the following to look over. If they insist — there’s nothing left to stay with.

Having digressed a little too much, let me take a technical look at why OLE is a terrible way to automate Office files. I have long since abandoned the OLE based automation approach in my project. As for alternatives, I will use open source NPOI for general projects, and commercial solutions for some particularly complex or special projects. Established manufacturers such as Infragistcs, DevExpress, Syncfusion, Telerik, Aspose, etc., all have good components to adopt. Aspose also wrote a special article to elaborate on this issue, which I think is very comprehensive, so I will directly translate this article. As a component manufacturer, it is inevitable for Aspose to advertise its own products in this article, but from the technical point of view, the viewpoints of this paper are all credible. In addition, this article quotes Microsoft itself (see the link at the beginning). There’s no excuse for Microsoft to hack their products. This article has cited Microsoft’s important point of view, that article I will not continue to translate, interested in their own click to see.

Interest: I have no relationship with Aspose and have no intention of promoting them. From the perspective of pure users, the products of Aspose are very good. However, the products of several other manufacturers also have their own advantages, so you can choose the products you are familiar with. Open source NPOI and the like are adequate for most Excel processing tasks as long as they are not particularly complex scenarios.

Let’s get started.

译 文: Why Not Automation

Why is the Aspose component a better choice than Microsoft Office Automation?

introduce

Two of the most common questions we hear in Aspose are:

  • Do you need to install Microsoft Office to run your products? Short answer: “No”. The Aspose component is completely independent, not owned by Microsoft, and does not need to be licensed, sponsored or approved by Microsoft.
  • Why use the Aspose product instead of using Microsoft Office automation? The short answer is that there are a number of reasons, the main one being that Microsoft itself strongly advises against using Office Automation in software solutions: Considerations for Server-side Automation of Office.

There are several reasons why the Aspose component is a better solution than automation. Among the key reasons:

  • security
  • The stability of
  • Scalability/speed
  • The price
  • function

These points are described below. Also, be sure to read the link at the end of this section.

security

The following is a direct quote from the Microsoft article above:

Office applications were never designed to be used on the server side, so the security issues faced by distributed components were not considered. Office does not authenticate incoming requests, nor does it prevent you from inadvertently running macros or starting other service instances that might run macros. Please do not open files uploaded to the server from anonymous networks! Based on the security options you set up last time, the server can run macros in the administrator or system context with full permissions, damaging your network! In addition, Office uses a number of client-side components (such as MAPI, WinInet, and MSDAIPP) that cache client-side authentication information for faster processing. If Office automation is used on the server side, an instance can serve multiple clients, and because authentication information is already cached in that session, it is possible for one client to use credentials already cached by another client to impersonate another user to gain unauthorized access.

Aspose products are very safe. The Aspose component runs with an ASP.NET user account and has the same context as other ASP.NET applications. As a result, the Aspose component does not pose a potential risk to critical system resources. In addition, macros do not run automatically when the Aspose component opens the document. The Aspose component is built to allow developers to create, manipulate, and save Office files. Any risks associated with Microsoft Office packages are not carried into the Aspose product.

The stability of

The following is a direct quote from the Microsoft article above:

Office 2000, Office XP, and Office 2003 use Microsoft Windows Installer (MSI) technology to provide installation and self-repair capabilities for end users. MSI introduces the concept of “install at first Use,” which allows dynamic installation or configuration of functionality at run time (at the system level, or more often at specific user users). In a server-side environment, both of these degrade performance and increase the likelihood of dialog boxes that require the user to allow the installation or provide an appropriate installation disk. While this increases the resiliency of Office as an end-user product, the MSI capabilities that Office implements are counterproductive in a server-side environment. In addition, the stability of Office as a regular product cannot be guaranteed in a server environment because it is not designed to be such an application. Using Office as a service component on a web server can reduce the overall stability of the machine. If you plan to use Office automation on the server side, try to isolate the program to a dedicated computer to avoid affecting critical functions, and you can restart as needed.

Since the Aspose component is packaged into a single DLL, no additional attachments need to be installed to use its functionality. The Aspose component is provided only by. NET applications, no code needs to wait for a reply from a human user. The Aspose component has been thoroughly tested. The Aspose component is used by IBM, Hilton, Reader magazine, and Bank of America, among others.

Scalability/speed

The following is a direct quote from the Microsoft article above:

Server-side components should be highly resilient, multithreaded COM components that consume few resources and provide high throughput for many users. Office apps are the opposite in almost every way. They are non-reentrant, single-threaded suite (STA-based) automated servers designed to serve a single user, but consume a lot of resources. For server environments, they have minimal extensibility and fixed limitations on important elements such as memory that cannot be changed through configuration. More importantly, they use global resources (such as memory-mapped files, global add-ons or templates, and share automation servers), which limits the number of instances that can be run concurrently and can lead to competition if used in a multi-client environment. Developers who plan to run multiple Instances of Office applications simultaneously need to consider pooling or serializing access to Office applications to avoid potential deadlocks or data corruption.

The Aspose component is highly scalable and lightning fast. Office applications are not designed to be used by hundreds or thousands of users at once; The Aspose component is designed for this purpose. Our component is a real. NET solutions, whether running a single application on a single server or supporting enterprise-level applications in a load-balanced Web Farm, are perfect.

The price

If you use Microsoft Office automation with your program, you must purchase a copy of Microsoft Office for each computer on which your application is running. Many times an application may need to create or manipulate Office files, but the user is not required to have Office. Aspose provides a very cost-effective, royalty-free, redistributable license that allows deployment to an unlimited number of users without worrying about licensing issues.

When creating web-based applications, it is important to know that Microsoft Office Automation components are not priced or licensed for a server-side solution (only Office 2000 Web components and Office server extensions are licensed). Therefore, there is no good licensing solution for deploying Web applications that use Microsoft Office components. Aspose provides a very cost-effective solution for server-based applications.

function

The Aspose component provides everything you need to manage Office files, and much more. They are designed to allow developers to achieve maximum results with minimal effort. Unlike Office automation, the Aspose component provides many powerful, time-saving features. Asposed.Cells, for example, provides developers with the ability to export directly from a DataTable or DataView to an Excel file. Aspose.Words provides similar functionality, allowing developers to populate Word mail merge documents directly from any.NET data object. Each component in the Aspose collection provides its own set of unique and powerful functions.

The best way to purchase Aspose components or component kits is to visit our development team. Our development team realizes that if your company needs functionality, other companies may need it, too. Not every feature requirement is added, but our team is very open and flexible when it comes to helping. These ideas are what help make the Aspose component so powerful. Even if you need additional functionality from Office Automation objects, it’s highly unlikely you’ll need to add them.

conclusion

This article Outlines the key points that the Aspose component is a better choice than Office automation. All of the various Aspose components are available in risk-free, evaluation-free versions. We encourage you to take advantage of this assessment to better understand what Aspose can do for your application.

For more information, see the following Internet article:

  • Top 10 Reasons for Developers to Use the.net Framework 1.1
  • Aspose vs. Office Components
  • Considerations for Server-Side Automation of Office
  • Licensing the Office 2000 Web Components and Office Server Extensions