OffBeatMammal

Searching for monkeys in Cyberspace

Adding effects to Powerpoint via Open XML

clock June 22, 2007 04:07 by author OffBeatMammal

Thanks to Doug for introducing me to another neat trick you can accomplish thanks to the magic of Office Open XML (the file format underlying Office 2007) is programmatically adding effects to a Powerpoint presentation.

In a web scenario this could be used to fine tune a customized presentation before delivering it to the end user as a download.

To start with you'd need to create your basic presentation and save it as a .pptx file.

Create a PPTX and save it. In the same way we did for a .docx or a .xlsx in earlier examples rename the file to a .ZIP extension, and drag one of the slides in ppt\slides to the desktop.  Edit that XML, and add a transition element as the last child of the <p:sld> element.  For example, you might put the following markup between </p:clrMapOvr> and </p:sld> ...

<p:transition>
  <p:newsflash/>
</p:transition>

Now you have a transition effect on entering that slide.  Try fade instead of newsflash if you'd prefer something more subtle or see a more complex example.



Use Open XML to turn on revision tracking

clock June 20, 2007 20:27 by author OffBeatMammal

When you're creating a Word document from a script you may want to activate something like revision tracking by default. Like the previous Open XML tips this one is surprisingly simple thanks to the power of the new underlying format (and Doug for pointing me in the right direction).

To see it in action, fire up Word and create some content. For example, type =rand(P,L) and press ENTER (where P=#paragraphs, L=lines per paragraph), or type =lorem(P) and press ENTER (where P=#paragraphs).

Following the instructions here edit the word\settings.xml part and add a <w:trackRevisions/> element as the first child of the <w:settings> element.  Now when you open the document, revision tracking is on. For more information about revision tracking and what it can tell you when you subsequently open the document via code have a look at this article at OpenXML Developer.

On, in case you were wondering about those magic functions =rand() and =lorum() check out TheNewPaperclip for more explanation and other great information about Office 2007.

More to follow....



Open XML - separating data and presentation in a Spreadsheet

clock June 20, 2007 06:10 by author OffBeatMammal

So, I recently discovered that by renaming an Open XML document to .zip allowed me to find elements within it. It turns out that there's a lot more you can do with it and following an email conversation with Doug Mahugh (our resident Open XML guru) I discovered that there's a bunch of other cool tricks you can play because you can get at the data directly.

You can edit any of the XML parts by just dragging them to the desktop, opening in IE, View Source and make changes, save, drag back into the ZIP package, and rename back to DOCX/XLSX/PPTX.

The first one of those is separation of presentation and data in spreadsheets

Create a spreadsheet with a column of random numeric data in it.  For example, type =RAND()*100 into A1, then drag the lower right corner of A1 down to A20.  Then click on Conditional Formatting and pick something you like.  Save the XLSX, open as a ZIP, and check out xl\worksheets\sheet1.xml.  The sheetData element contains all the data, and the conditionalFormatting element afterward contains the conditional formatting definition (and the range it applies to, in the sqref attribute).

This demonstrates nice clean separation of presentation and data, which occurs many places in the Open XML formats.  You can edit the sheetData or conditionalFormatting separately, or delete the conditionalFormatting (or change its range) without touching the data.

This gives you great opportunities to programmatically update the data (or presentation) from, say, a web application and then push the resulting file back to the user.

If you're working with Open XML documents from a server you're not limited to using the Microsoft platform, it's equally possible from PHP etc and most of the heavy lifting is already bundled into easy to use libraries for popular platforms.

More to follow...



Cool trick with Word 2007 documents

clock June 19, 2007 05:19 by author OffBeatMammal

So you know all the good stuff about Office 2007. The performance improvements, the Ribbon UI (which I'm really learning to love) and of course the advantages of the new OpenXML based file format.

Now normally there's not much to interest me in the bits and bytes of a file format (well, not in the last few years where I've tried to take a bigger picture view of the world) but because of the structure of the new .docx format there's some cool things you can do.

First part of the trick is knowing that by changing the file extension from .docx to .zip you can expand the file/directory structure using WinZIP or directly in Vista. You can then navigate the content and find just the bits you need.

The cool bit is how easy it is to get at any images included in the document, helpfully presented in order in the \word\media directory so if someone sends you a file and you just want the images... it's easy to get at 'em.

What else you can do... well it's up to your imagination...



Search

Calendar

<<  March 2010  >>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Sign in

Twitter


    follow OffBeatMammal at http://twitter.com



     
    Donate unused CPU cycles with BOINC Stats and Account Management from BOINCStats.com



    Blogroll

    Archive

    Tags

    Categories


    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010