OOXML Hacking: Graduated Color Table Borders

I’ll admit right off the bat, graduated color table borders is a trick you might need only once every ten years. But it’s a good illustration of the little touches you can add with XML Hacking that you just can’t do any other way. If you’re unfamiliar with XML hacking, please read XML Hacking: An Introduction. If you’re using a Mac, you should also read XML Hacking: Editing in OS X.

I was working on a presentation for a designer and the theme used graduated color rules. Most of the layout only need a rule below the title, which was simple to do with user interface. But then the designer included a slide that clearly needed to be a table and that table had the same graduated colors used as horizontal borders. At first, I informed him this wasn’t possible, but as I researched the issue, I found there was a way.

The answer was in a 10-year-old blog post by Mike Fried. Back then Mike was one of the engineers creating Office 2007 and his 2 posts on PowerPoint table styles have lots of good information. Toward the bottom of the article, he included garish graduated color table borders. It was enough to crack the code.

As an aside, I’d like to mention that you can find out the details on any Open Office XML parameter by Googling it. There is extensive documentation on the web, even though some of it is terse database excerpts. The essential command for a gradient line is a:gs. The GS stands for Gradient Stop, the points on the line that define where a particular color appears in the graduated line.

Googling ooxml a:gs gets you the Datypic site that lists elements and attributes, but explains almost nothing about them. However, this site can be useful because all XML elements are hyperlinked, so you can quickly find related parameters.

Further down the page is the openofficexml.com page on a:gs. This site has relatively verbose explanations of the element, a clear example of useage and definitions of the elements included in the xml object.

Finally, many searches will turn up links to the Microsoft MSDN developer pages about Open Office XML. These discuss Themes and XML in a more conversational style that is great for picking up the overall concepts. Occasionally, you’ll also find a valuable blog post, such as Lars Corneliussen’s explanation of Open Office measurements units.


Graduated Color Rules

But back to graduated color table borders! First, let’s look at a graduated color rule, which you can create using the program interface. Here is the dialog box showing the settings. The central point of the gradient has been shifted to the left to have more solid color on the right side and a rapid dropoff to white on the left:

Graduated Color Rule Settings

Here’s how the rule looks:

Graduated Color Rule

When we examine the XML for this rule, it looks like this:

<a:ln w="19050">
  <a:gradFill>
    <a:gsLst>
      <a:gs pos="0">
        <a:schemeClr val="bg1"/>
      </a:gs>
      <a:gs pos="25000">
        <a:srgbClr val="B7E6FF"/>
      </a:gs>
      <a:gs pos="100000">
        <a:schemeClr val="accent1"/>
      </a:gs>
    </a:gsLst>
    <a:lin ang="0" scaled="0"/>
  </a:gradFill>
</a:ln>

The pos (position) parameter is a percentage of rule length, with 100000 representing 100 percent. The colors are straightforward, with bg1 being the white background and accent1 the cyan. For the midway color value, I used the handy RGB Tint Calculator on this site, but then moved that value to the 25% mark.


Graduated Color Table Borders

The XML for a rule translates exactly to the XML for a table style. Here is the style for the top border, the same XML is applied to the inside border so that all interior rows show the same rule:

<a:top>
  <a:ln w="19050">
    <a:gradFill>
      <a:gsLst>
        <a:gs pos="0">
          <a:schemeClr val="bg1"/>
        </a:gs>
        <a:gs pos="25000">
          <a:srgbClr val="B7E6FF"/>
        </a:gs>
        <a:gs pos="100000">
          <a:schemeClr val="accent1"/>
        </a:gs>
      </a:gsLst>
      <a:lin ang="0" scaled="0"/>
    </a:gradFill>
  </a:ln>
</a:top>

Here’s what the final table rules look like with the table style applied:

Graduated color table borders

For more information on how to create table styles, please read XML Hacking: Custom Table Styles, XML Hacking: Table Styles Complete and XML Hacking: Default Table Text.

6:26 pm

Leave a Reply

*Required fields. Your email address will not be published.

Posting XML? To enter XML code, please replace all less than signs "<" with "&lt;" and greater than signs ">" with "&gt;". Otherwise, Wordpress will strip them out and you will see only a blank area where your code would have appeared.