Although Microsoft is not happy about it, much of the world has been moving in the direction of the XML-based OpenDocument format, otherwise known by it's much longer, full name: the OASIS Open Document Format for Office Applications.
This opens up new possibilities for document generation and allows the creation of all sorts of Office-type documents using only a text editor (assuming you know what you're doing). A number of applications, including OpenOffice, already support the OpenDocument format. Microsoft Office does not, but there are plugins available.
To use these files in Microsoft Word, you'll need the ODF add-in for Word. There's other add-ins on the way for Excel and PowerPoint, or you can also use Sun Microsystem's OpenDocument plugin for Microsoft Office, which supports all 3 applications right now and allows you to open your OpenOffice documents, spreadsheets, and presentations within MS Office.
So why use ODF? Well, for one, it's open and non-proprietary, so you won't be locked into using a specific brand of word processor in order to edit your files. Secondly, and most important to this post, is that it's text based, so we could theoretically store the content of our documents in a database, and generate them on the fly as needed. That's what we're going to demonstrate.
It's important to note that although the documents are XML-based, in most cases they'll come packaged as a zip file with the extension changed to represent the type of file and to make sure they get opened up with the correct application.
To demonstrate, I've created a sample document in OpenOffice which you can download here. I also created a copy and renamed it to sample1.zip, which you should be able to unzip to see what this document is really made of!
OpenOffice actually creates some extra stuff that's not required, including a "Configurations2" directory, as well as a "Thumbnails" directory containing a png screenshot of the document. The stuff that's required are the files in the root of the zip, as well as the META-INF directory. The structure should look something like this:
/
-- content.xml
-- meta.xml
-- mimetype
-- settings.xml
-- styles.xml
/META-INF
-- manifest.xml
The files that change for each document are meta.xml, which contains the meta info for this specific document including author, creation time, etc. Styles.xml allows you to setup styles which then get used in content.xml, which contains the actual content of the document. Setting up styles is beyond the scope of this blog post, but the OpenDocument spec explains all of the inner workings. There's also a repository of sample documents available.
Generating these documents in ColdFusion requires the following steps:
The entire script used to generate the document is only 138 lines and can be downloaded here. You can also try the online demo is available which will spit out out a generated document on the fly.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
Project Tracker v2.0 Released
Joe Danziger said: @Doug - thanks, glad you like the app! You can add the following to the <cfapplication> call ...
[More]
Project Tracker v2.0 Released
Doug said: Great App!
How can I increase the time before the session times out? thanks!
[More]
Project Tracker v2.0 Released
Joe Danziger said: @Ron - You can access the demo with username admin and password admin.
[More]
Project Tracker v2.0 Released
Ron Stewart said: Joe: from the screenshots and the blog entries, this looks pretty cool. I'd like to play in the demo...
[More]
Project Tracker v2.0 Released
Mike G said: very very very nice work Dan, nearly blew my load when I saw you even included an API to access ever...
[More]
There are no comments for this entry.
[Add Comment]