The packaging API in the .NET 3.0 framework (formerly known as WinFX) provides low-level support for reading and writing Open XML documents. And now that Office 2007 Beta 2 is out, more developers are starting to ramp up on how to work with the packaging API. (If you've not seen the new packaging API, you can download the WinFX February CTP to check it out.)
Over the next couple of weeks, I'm going to be writing some simple programs that will serve as learning tools for working with the packaging API. Eventually, I'll probably enhance these programs to make use of the handy code snippets that have been published for working with the packaging API, but before I get into that I wanted to provide bare-bones samples of how to create the most common types of Open XML documents:
If you're already up to speed on all the details of Office Open XML, you know that there are many other variations: macro-enabled documents (DOCM, for instance), XPS documents, and so on. For now I'm going to ignore those variations so that we can focus on a single narrow objective: learning how to create Open XML documents with the packaging API.
Here are the three utility programs I'll be posting here soon:
CreateDOCX. Creates a specific DOCX file, containing specified text. Very simple, no formatting, just the basics of how to create a DOCX. Later we can add support for an RTF textbox and start playing with formatting.
CreateXLSX. Creates a specified XLSX file, containing a single row with specified values (supporting both numeric values and text strings). This is more complicated than the DOCX example, because of the way shared strings are stored.
CreatePPTX. Creates a specified PPTX file, containing a single slide with a specified title.
These are all simple command-line programs, written in C# and compiled in Visual Studio. I'll be packaging them in command-line versions so that the code can be lifted and used as a starting point in any type of .NET program such as a Winform, a web page, or a web service. And after I get them cleaned up a bit and ready for prime-time, I'll post the code to the OpenXmlDeveloper web site. If you're new to Open XML development, that site is the place to start.
My next post will cover the details of the CreateDOCX program.
PingBack from http://jointpainreliefs.info/story.php?id=500