Developers usually waste 90% of their time thinking how to generate Office format documents. Perhaps that is what is being used by most companies and developers right now. Microsoft Word, PDF, Rich Text Format and other similar formats are in high demand these days.
Creating a custom interoperability service is a very time-consuming and a less efficient function when the solution type for your application is enterprise. Third-party applications provide a very good solution to such tasks that can enable us to kick-start our applications in a matter of a few minutes.
Spire.Doc (by E-Iceblue) is one of them. I have personally tried the software library for the .NET Framework and it is kind of a helpful tool for .NET developers (no matter whether you are a Windows Forms, Windows Presentation Foundation or ASP.NET developer) for generating cross-file format files.
Note: By cross-file format I mean you can generate the output in a number of formats, file based (under files, this library supports PDF, Microsoft Word, HTML web pages, Rich Text Format and more), it also supports generating images for your documents and to get the streams for your document resources.
Spire.Doc API: I have used Spire.Doc (and other connected APIs and namespaces) to provide it a quick look and start. If someone has a great understanding of how these documents are, what a paragraph is and what can be added to various components.
The very basic document in Microsoft Word would require only:
- Single document object.
- Single section to contain the data. This is also the page of your applications document.
- A number of paragraphs, depending on whether and what you want to add to the document. The paragraph would allow you to add images or other stuff, such as text and characters; symbols in Unicode format you just need to the integer value for the Unicode character.
- Tables are also added to the section object, if required.
The Spire.Doc namespace also allows you to save the document, in any number of formats, ranging from PDFs to a wide variety of Microsoft Word formats.
Note for E-Iceblue developers
I have had a few intuition problems using the product, for a .NET developer, adding a new element to the current child hierarchy is something like the following.
- var element = new Element();
- // Any properties or similar editions
- parentElement.Children.Add(element);
- var element = parentElement.AddChild();
- // Child type is determined by the function called, AddParagraph, AddTable etc.
- // Then element is edited out.
A few code samples for readers
Since review-only posts are not my style, I would provide a few code samples to the readers also, as if to show how easy it is to use the Spire.Doc library for their personal use. As already said, this is a library for the .NET Framework, the library is consumable by every framework (although, E-Iceblue also ships the library in various versions, one for every framework on .NET).
The same code sample would work on Windows Forms, Windows Presentation Foundation, SilverLight, ASP.NET and (as I have tested it enormous times on) Console applications.
Documentation of the Spire.Doc is available along with the package when you download it (and it is a very great and intuitive documentation, with a style pretty much as that of the MSDN). You can always use the documentation application, to read the API and continue where you get stuck when developing the application.
Loading a new document
Loading the new document is similar, whether you are trying to create a new document, or load it from an existing file. Spire.Doc provides you with constructors that can be used to initialize the Document object.
- // First method, new document
- var document = new Document(); // works
- // Second method, existing document
- var document = new Document("path", FileFormat.Docx);
Once loaded, you can then work with a document to add a new section, paragraph or other similar object or to edit the existing objects in the document.
Editing the document
Editing the document is another key feature of this library, because it not only lets you create new documents but also allows you to edit already existing documents and files, no matter what data type they hold. The key points are that you can edit the document (of any type) and save it (in any format).
You can add new paragraphs or sections to your document that in turn allow you to add images and text to the document. (As already said above) I do have a little problem with this process in the Spire.Doc namespace, but still it is a great way of handle-oriented programmers that have a great intuition for creating the object then saving the handle for further processes.
- // Creating a document, adding a section and a new Paragraph.
- var document = new Document();
- var section = document.AddSection();
- // update the section, if required
- var paragraph = section.AddParagraph();
- // Update the paragraph, for example.
- paragraph.AppendText("Love for all, hatred for none!");
- paragraph.AppendPicture(imageObject); // accepts System.Drawing.Image object.


Vijaya ChikkamathPosted Jun 14, 2017, 2:06 AM
Does it help convert only word to other formats and vice versa? We have a requirement where we should be able to convert any file type to html.. Example: doc, docx, xls, xlsx, txt, ppt, pptx, to html
NitinPosted Jun 15, 2015, 9:32 AM
good one
Atul GuptaPosted Jun 15, 2015, 3:14 AM
Good Article ,thank you for sharing knowledge!
Rahul Kumar SaxenaPosted Jun 15, 2015, 2:30 AM
Good Show..
Van LaiPosted Jun 14, 2015, 9:31 PM
Thanks a lot for sharing
Santhakumar MunuswamyPosted Jun 12, 2015, 2:27 PM
Thanks for sharing