Introduction
While I personally don’t get many requests for Office Automation-type projects these days, as a consultant, it is good to have a go-to library to use should the need ever arise. Some time back, I was contacted by one of the sales executive from E-IceBlue to review one of their products Spire.Doc
Spire.Doc for .NET is a professional Word .NET library specially designed for developers to create, read, write, convert and print Word document files from any .NET( C#, VB.NET, ASP.NET) platform with fast and high quality performance. As an independent Word .NET component, Spire.Doc for .NET doesn’t need Microsoft Word to be installed on the machine. However, it can incorporate Microsoft Word document creation capabilities into any developers’ .NET applications.
How to get it?
Gone are the days when we used to get the boxed software and unboxing, unpacking them used to be an experience itself. You can download and eventually purchase the Spire.Doc from their website.
The Spire.Doc installation is clean, professional and wrapped up in a MSI installer. The first few slides are mandatory informatory and license agreement. By the way, when was the last time you read the whole EULA? Usually standard text, but if you are a company who is going to invest and use the product for commercial reasons than it’s a good idea to read the agreement for any software.
The Spire.Doc does not take much space (only 180 MB) for installation. Makes me nostalgic, not long ago (~ 10 years) most of were still happy with our 1.44 MB floppy disk drive.
The MSI option provides a full experience, including:
-
Installs the assemblies (multiple assemblies to support different versions of the .NET Framework)
-
Installs the demo projects with source code
-
Installs the documentation locally on the developer’s machine
-
Adds the assembly to the Add Reference dialog box in Visual Studio
After the installation, the developer must manually add a reference to the assembly. Locally-installed documentation is available by means of Windows HTML Help, which is completely available and searchable while disconnected from the Internet.
Hello World
One challenge that we had with writing the document generator all those years ago was finding an efficient way to insert formatted text into the document. Specifically, the resulting document contained sections of text, each with paragraphs and special formatting. Because of time constraints, the decision was made to not build a document on-the-fly by inserting text into it, but instead start with a document that had every possible section already in it (nicely formatted by a human), and then just delete sections based on the user’s input.
Let’s start with the customary Hello World program to write a small word document using Spire.Doc.
Here are the steps:
-
I will use the good old Console Application project to demonstrate the program.
-
Within Solution Explorer, go to Reference and add a new reference to Spire.Doc.dll
-
I wanted to see how intuitive is the naming convention of Spiral.Doc are. So I started without looking at their documentation to juggle around and using the object browser to check the available interfaces. From my first guess, I thought something like below should help me to create my first output.
-
The result? It worked flawlessly.
If you have a license then the evaluation waning should go away.
-
While we are already busy with it, let’s see if it is possible to export the word document to pdf or html.
Well, not bad that just with one line of code I can convert and save my word document to pdf. This is quite handy for we developers as there are almost daily business requirements for creating or converting word t pdf documents. From my personal experience, this is one of the hottest questions daily on any forum.
-
This was one of the simplest example, but there are possibilities to create document from reading html using a stream, inserting html, formatting the document or adding any meta data property to your document.
Supported File Formats
Being a developer, I am not a very big fan of large documentation. Although, Spire.Doc has documented and stated the file types they support. I went ahead and checked in their assembly enumeration what they actually support. The result was that it supports almost all major file formats you would encounter in your day to day basis.
Conclusion
Overall, I was impressed by the power and ease provided by this product. While it didn’t always do everything in the way that I thought it should, it is probably due more to my lack of understanding of how the Word document model works rather than a flaw in this library.
From a license and pricing overview, it’s not very expensive compared to other products in the markets which are offering the same functionality. Thus, a real value for money in my opinion.
Disclosure of Material Connection: I received one or more of the products or services mentioned above for free in the hope that I would mention it on my blog. Regardless, I only recommend products or services I use personally and believe my readers will enjoy.
Be First to Comment