logo

Export Notes Data To MS Word

Earlier this month I talked about Office XML and promised some examples for the following day. Woops. Better late than never I suppose, here's a demo of using Notes data to create a Word document.

First, create a New Press Release. Fill in the blanks and press the save button. You'll then be in the document in read mode. You should see a Word icon that is a link. Clicking this in non-IE browsers will open a complex-looking XML file. In IE it will probably prompt you like so:

grab

Click open and Word will launch inside IE and show the information you just entered within the new document. Click save and the XML is saved to disk as a file that will open in Word when double-clicked.

Whether or not this works may depend on the version of Office you have installed. I have Office Professional 2003. If you have any other version I'd like to hear if this does/doesn't work and what happens. I think this whole Office XML thing might only work with later versions.

How did I do it? Easy. I took this example file and pasted the contents in to a form called "PressXML", set to use a content-type of "text/xml". I then created a form called "Press", with the fields used to store our data. This form has the Word icon link on it. The link opens the document through a view called "word", whose Form Formula forces it to use the "PressXML" Form. The PressXML Form has been edited so that the fields with our data are in the right places to show the values in the Word document. It doesn't get much easier than that.

I'll do something similar to create Excel files and then I'll polish up the OfficeXML.nsf DB to make it good for download. Not sure if it needs an article though.

More on Office XML.

Comments

    • avatar
    • jono
    • Fri 22 Jul 2005 04:09 AM

    I tried using IE6, Office XP and when I clicked on the word link it just opened the XML file in IE - no word...?

    • avatar
    • YoGi
    • Fri 22 Jul 2005 04:22 AM

    i guess you must have office 2003.

    • avatar
    • Jake Howlett
    • Fri 22 Jul 2005 04:36 AM

    Yeah, it's starting to look like a 2003 thing. How prevalent is 2003 in the office (note lower-case o) out there me wonders?

  1. This could be very interesting for us. Office 2003 not a problem, but would like it to work either with IE or Firefox. Also would like to able process documents from a view, rather than lauching each document

    • avatar
    • Caroline McGrath
    • Fri 22 Jul 2005 05:53 AM

    IE 6 and Word 2000 doesn't work.

    Where did you get the example XML file from? Could there be another one for other versions of office/ word?

    • avatar
    • Jake Howlett
    • Fri 22 Jul 2005 06:26 AM

    The example is from the O'Reilly book, which you can download here {Link}

  2. Here's a scenario - I don't have Word but do have Open Office. The xml doesn't open directly from IE, but if I save it and open it with OOo, it looks like this:

    {Link}

    I assume that's what it should look like since it's an xml standard. Just FYI...thanks!

    • avatar
    • Jake Howlett
    • Fri 22 Jul 2005 07:47 AM

    That looks like a fair attempt at rendering it by OOo. Although it's not perfect. In Word the table was borderless for a start...

  3. What application is opened by the browser, when it receives a certain mime type, can be set within the browser. It is dependent upon what mime type is sent from the link. Different methods for different browsers. Gimme a sec to find links

  4. I tied it with XP pro sp2 + IE 6 + Office 97, Only got the xml.

  5. Only Office 2003, XP and later will recognise the XML (and OOo). From what I've [i]heard[/i], The XP version generates content not recognized by 2003.

  6. I just realized that for Office, are not the browser plug-ins an install option? Maybe some do not have them installed. Anyway, a better way may be to send it to the browser with the same content-type, but add on a content-disposition to the header.

    {Link}

    * shrug * might work

    • avatar
    • Ian
    • Fri 22 Jul 2005 09:31 AM

    Man! I'm on Word 97 at work - maybe I'll try this in 10 years or so....

  7. with a mac running Safari 2.0...

    clicking the Word icon gave me gibberish in Safari...

    I downloaded the linked file to my machine, tried to open in Word X for mac SR1, looked like an XML file...

    I opened the .xml file with Apple's Text Edit, voila, looked like a nicely formatted press release!

  8. {Link}

    This recent article from the Register claims that only 15% of PCs are runnng Office 2003 - seems to be verified by the results seen in the comments to this article. Like most MS products - they work great in a 100% MS world.

  9. We have been using Jakarta POI {Link} which is a Java API to read/write office files directly. I haven't played with output to Word (yet) but the Excel APIs work a treat. This works for Office97.

  10. Just render your output through Ghost Script and send out pdf files. :-)

    {Link}

    a friend of mine had this working in Notes 4.6 years ago. Nice as most users have domnloaded the adobe reader plugin for their browser of choice already.

  11. More...

    If your interested in making .pdfs, I really recommend considering the use of java and read this.

    {Link}

    Ghost script takes postscript as input, according to my friend who has played with it. In any case, you're going to produce output for transformation into the target format. The java path will lead you toward XSLT and other exciting things.

  12. The code works although the output on the word document is not formatted the same way I entered it on the web form. I entered the items in bullets and was wrapped around. Is there a way to eliminate this and show the content field the same way its entered on the web form?

    • avatar
    • Damjan
    • Thu 20 Dec 2007 07:17 AM

    Where can i download this example?

    • avatar
    • Jens
    • Fri 16 May 2008 03:03 AM

    Cannot find the download of the officexml.nsf. Is it available?

    Thanks

    Jens

    • avatar
    • Jake Howlett
    • Fri 16 May 2008 03:56 AM

    I never made the database available for download as it's so simple that it didn't seem worth it.

    All you need to do is paste the example XML on a form and replace the data parts with fields.

    Jake

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Fri 22 Jul 2005

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content