Thursday, 5 March 2009

Introducing the Simple OOXML library

The new xml based document formats (.xlsx, .docx, .pptx etc) introduced with Office 2007 finally provided developers with the ability to create documents on a server without having to have either MS Word or Excel installed or to use a 3rd party component.

However producing this Xml is very complicated and it's certainly not a pretty format. The OOXML SDK goes as far as wrapping the Xml elements of the specification into a set of .net classes, but still falls short of the higher-level functionality required to actually create documents. Some open source libraries, such as ExcelPackage, are incomplete or discontinued and I wanted to create a simple, robust fully supported library that fits right into the object model of version 2.0 of the sdk.

The project addresses this issue by providing a layer of abstraction over version 2.0 as a set of simple classes and methods to create new spreadsheet (Excel) and word processing (Word) files with the following benefits:

  1. No Excel or Word is required on the server.
  2. No in-depth knowledge of the OOXML standard or SDK is required.
  3. New documents can be created or existing templates can be modified.
  4. Ability to stream directly to the browser or between servers
  5. High performance
The following table outlines the classes used to create and read office open xml documents:


Static functions used to create new word processing documents.


Static functions used to paste text items into a word processing document using bookmarks and save the document to a stream or file.


Static functions to create new spreadsheet documents and to retrieve worksheet, column and row references. Get style and defined name range parts.


Create an object that can set style, color and font information in a spreadsheet and retrieve and compare style parts.


Static functions to create style parts in a spreadsheet, control shared strings and helper functions when working with spreadsheet documents


High level and static fucntions to retrieve cell and style information from a worksheet.


High level and static functions to write text, numeric and datatable based values to a worksheet. Draw borders, insert rows, merge cells and set print areas.

Simple OOXML requires version 2.0 of the OOXML SDK which can be found here:
In my next series of posts, I'll show how easy and powerful this library is.

(The DocumentFormat.OpenXml.Extensions.Testing unit test project included in the source on Codeplex contains samples of almost every type of operation supported by the library.)

No comments: