Partager via


Let's talk w:tbl!

In one of my earlier blog entries, I introduced some of the bread-and-butter XML element in the WordML schema. I have been expanding my horizons with other markup. Intriguingly, I have been asked, "Do you really sit down and read the spec?" The answer is: Yes, I do. It reminds me of when I taught myself Russian (mostly, although I am grateful to the teachers of two intro classes I took). I used to conjugate EVERY verb in the book, in every tense, in every person- including the verbs I could find in the instructions. It was ...fun?

Anyway, one of the most common tasks in a Word document is to create a table. So what do the tags for that look like? Well, the one to get your table going is w:tbl (I have included the namespace alias here: w). All of your table formatting and content needs to go in between this tag's opening and closing. Usually, you will want to set some properties for the table, so, in a move that is like the other elements I have discussed, you have a tblPr element that lets you set up property settings for the whole table. For example, you may want to specify a style (tblStyle) or a width (tblW), indenting (tblInd), or some row formatting (tblLook). Here's my table:

Here's what the preamble to my table looks like:

       <w:tblPr>
<w:tblStyle w:val="TableGrid"/>
<w:tblW w:w="0" w:type="auto"/>
<w:tblInd w:w="604" w:type="dxa"/>
<w:tblLook w:val="01E0"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="8856"/>
</w:tblGrid>

The two that could seem a little confusing are the tblInd and tblLook settings. The first is the width of the table indent. You can set it by auto, twips, or as a percentage. If you choose percentage, then keep in mind the value is 1/50th of a percent. Yeah! The second one, tblLook specifies what aspects of the table styles should be included for row formatting. It is specified as a bitmask of options: 0x0020=Apply header row formatting; 0x0040=Apply last row formatting; 0x0080=Apply header column formatting; 0x0100=Apply last column formatting.

I'll spill out the rest of the table elements later.

Rock thought for the day: I spent some solid time working on chops on my Washburn this weekend. My fingers are sore. It's one of the best feelings I know.

Rock on.

Comments