Custom Table Styles are probably one of the more detailed hacks you’ll have to write. See the constructions details in my previous post. Besides the basic table format, there are 6 optional format layers you need to at least consider. In a minimal table style, you’ll need to include at least the Header Row, First Column and Banded Rows. Most users will expect to see these options. Total Rows, Last Columns and Banded Columns are less requested, you only need to include them if a design or client specifically requires them.
As mentioned in part 1, if you haven’t hacked XML before, please read XML Hacking: An Introduction. If you’re using a Mac, you should also read XML Hacking: Editing in OS X. In addition, an essential companion to this pair of articles is the post on setting Default Table Text, which is set in a different XML component..
Let’s take a look at how our work appears in the PowerPoint interface. First, we’ll insert a plain vanilla table. By default this takes on colors and fonts from the current PowerPoint theme:
Next, we choose the Table Tools>Design tab, open the Table Styles gallery. Up at the top a new Custom section has appeared with our new custom table style:
Select the custom table style and the default table changes to match our design. This screen shot has all formatting options turned off, so effectively we are seeing the Whole Table formatting only.
Table Style Options: Banded Rows and Header
Using the options panel in the upper left corner, we can add some of optional formatting layers we created in XML. First, let’s turn on banded rows. If you remember, we only formatted odd-numbered rows, so the banding only changes rows 1 and 3 in our example:
Next, we’ll leave banded rows on and also add the Header row. This row doesn’t count as part of the table body, so the banding moves down 1 row:
Table Style Options: First and Last Columns
Next, we’ll turn off banded rows, leave the Header as is and add the first column:
Here’s the table with First and Last Columns checked:
Table Style Options: Header and Total
And finally, Header and Total Rows:
As you can see, with some pre-planning, one table style can cover quite a few related table looks. The layer options for different features make the table useful for many different purposes and the options panel makes it fast and easy for users to try different combinations. This feature is a major advance over tables in PowerPoint 2003 and earlier, which were quite crude by comparison.Table styles a similar way in Word, PowerPoint and Excel. While Word and Excel include table style editors in their interface, PowerPoint needs to be hacked to create them. Sadly, the table style specs for the different parograms are dissferent, so it’s not possible to trasfer tables style OOXML among Word, Excel and PowerPoint.
Table Styles: What You Can’t Do
You cannot set vertical cell/row alignment or cell margins in default taxt table text or a table style. It would have been possible given the OOXML spec, but Microsoft just didn’t bother.
Of course, if the process is too complex, we’re here to help. The current price on a custom table style is US$120. Just email me production@brandwares.com
Can I just pay you to do this for me?
Sure, that’s what we’re here for!
Is there a way to align text in middle of the cells?
Yes, this is possible. My post on Default Table Text covers setting text alignment, along with typeface choice and size, and whether the font is bold or italic.
thanks, i found that. but i was thinking in the middle vertically in the cell.
There is a fontAlgn parameter that does vertical text alignment, but unfortunately it does nothing in a table style. It’s only added when the user sets the vertical alignment after creating a table from a style.
Hey, my company would be happy to pay for you to help us with creating custom table styles. Please contact me.
Laura
Any reason why my custom table shows a generic icon instead of the standard (responsive?) one you have showing here?
To be honest, I don’t think I’ve seen that before. Please send a screen shot of what you are seeing to production at brandwares dot com. Thanks!
Actually, I was reading some of the comments here and acted on: adding the « noFill » tag, when I had set my borders to 0. This, I believe, cured my problem. I can now see the dynamic representation of my table in the Quick Access Bar instead of a generic one with the running timer icon on top of it.
Thanks anyway! 😉
Glad you got it figured out!
so i’ve been reading your pages for a few years now and every Nov-Dec, I review them when I try to clean up/make our ppt templates better for the next year. One thing i’ve never figured out is how/where I can generate a table ID. Is this important? can it just be a random string? in my templates are 3 legacy tables styles I’ve modified from year to year but this year i want to add additional options but can’t seem to figure how to get these IDs. If I make one up, it seems to invalidate my PPT file after I re-zip it. Any help would be great!
EXAMPLE: styleId=”{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}”
If you search GUID Generator, you’ll find several web pages that can create them for you.
Hello, John,
does this also work in PowerPoint 2010?
In the newer versions (16 and newer and Mac 2011) I have no problems but in 2010 the xml is not recognized.
Is there a difference in the interpretation of xml
Thanks
Don
The XML is exactly the same for all versions, Windows and Mac. Newer versions of Office add extra XML tags for new features, but the basic table style XML has not changed.
Hello, John,
I want a table with horizontal lines only. I have set the corresponding lines to W=0.
Unfortunately W=0 does not work in PowerPoint 2010. Is there another solution for “no line” ?
(It works fine in 2011/2016/2019)
Here is an excerpt. (
<a:tcBdr>
<a:left>
<a:ln w=”0″ cmpd=”sng”>
<a:solidFill>
<a:schemeClr val= “dk1″/>
I use a good editor. Any typing errors are probably caused by transferring the code to this site.
Thanks,
Don
It’s noFill instead of solidFill to set the borders to 0 ?
BR
Don
You can set the fill to noFill, or you can simply delete the entire section. Here is the wholeTbl section that only has rules for inside vertical borders:
Is there any way to permanently add 1 more table style to the defautl gallery in powerpoint? And if so how? Also where in exactly is that gallery saved ( I’ve found the themes gallery in office16, but I can’t find the tables gallery in the office files)
Hi John,
I’ve done my best to format my tables according to the specs laid out here. They look great on-screen and native but whenever we PDF them, we get these thin hairlines and I’m not sure how to get rid of them. By default, it feels like borders are all turned on so we manually set the default ones to have a with of 0 but now I’m wondering if this is still a cause of them showing up in the PDFs. despite having a width of 0, is acrobat picking up and creating a near 0 line simply because a line is defined. is there a way to say that for a border/side of the cell, to turn the line OFF as opposed to setting it to be 0?
I looked for the proper code for this but can’t seem to find it but I’m wondering that if such a command exists if this would fix the PDF issue. To solve it now, I have to go to every table, create border lines where there shouldn’t be any, and then remove them, and then the resulting PDF is fine.
Any insight would be great. Thanks and happy thanksgiving!
In addition to setting the line width to 0, remove the line fill color:
THANK YOU!
Hi.
Let me thank you for your work. You are the most knowledable on the internet I’ve seen for the subject of xml editing in Office. A question I had when trying to edit table styles via xml: it appears that, unlike the addition of an individual custom color using xml, or the addition of a palette of colors using the editor in the Variants->Colors menu of the Design tab, custom tables aren’t saved along with the theme when saving a .thmx file from the Design tab. If true, does that mean I have to start with my hand edited .pptx with its custom table themes every time I want to use them?
Thank you for any help
You are correct that tables styles are not saved in theme (thmx) files. To retain content like table styles, sample slides, and preformatted Notes and Handout masters, save the file as a template (potx) instead of a theme.
How do you turn on “banded columns” and turn off “banded rows” so it is a default when creating a table in PPTX in XML?
By default, PowerPoint has the options turned on for Header Row and Banded Rows, with all other options turned off. A table style alone can’t override those defaults. You would have to create an VBA add-in that captured table insertion operations to create a different behavior. Not a trivial task.
Hey John, was wondering if you could help me with some font_color hacking. I am trying to set custom colors to both background and the font color, but for some reason specifically the font color is stubborn. Here is a code snippit:
<a:tc>
<a:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:pPr algn=”r”/>
<a:r>
<a:rPr lang=”en-US” sz=”1400″ dirty=”0″ smtClean=”0″ b=”1″ i=”0″>
<a:latin typeface=”Verdana”/>
<a:cs typeface=”Verdana”/>
<a:solidFill>
<a:srgbClr val=”FFF000″/>
</a:solidFill>
</a:rPr>
<a:t>2000</a:t>
</a:r>
<a:endParaRPr lang=”en-US” sz=”1400″ dirty=”0″>
<a:latin typeface=”Verdana”/>
<a:cs typeface=”Verdana”/>
</a:endParaRPr>
</a:p>
</a:txBody>
<a:tcPr>
<a:solidFill>
<a:srgbClr val=”FF0000″/>
</a:solidFill>
</a:tcPr>
</a:tc>
As you can see it should be a red background with yellow text, but instead it shows red background with black text. This only persists for microsoft pptx as software such as google slides or keynote do show the yellow text. Any direction or help would be greatly appreciated!
XML hacking is most useful when you can’t do the operation through the program interface. You can set both the background and font color in PowerPoint. This is easier to do and more reliable.
Thank you, that makes sense. In this example though I am trying to convert a html table into a pptx table using a pptx library. Applying the background color and font color is a must in my case. Do you have any experience or suggestions on how I could troubleshoot this?
Sorry, I don’t know enough about your workflow to suggest a fix. We do consulting work for extending PowerPoint’s abilities with programming, we charge for that.
Thanks for the splendid documentation.
Is it possible to set the default template variant? I see that I can change <a:schemeClr val=”tx1″/> to e.g. tinted1. Powerpoint always uses txt1-tinted by default. I would like to make tx1 (without tint) the default. That’s one of the vertically shown variants in the table styles.
And: Can I set default options? I would like to deactivate Banded Rows.
PS: I posted a second time as I forgot to deplace < and >
It is possible to set a table style as the default by modifying tableStyles.xml. The a:tblStyleLst element has a def parameter that can be set to the GUID of the table style that is to be the default. The XML looks like this:
The text color for the table is set in a:wholeTbl/atcTxStyle. If you set just a theme color there, PowerPoint will not use a tint.
If you don’t want banded rows, just delete the XML for a:band1H and a:band2H.
Hi John… I read somewhere that for my default table layout I am unable to set the text to middle vertical? Is this possible?
That’s true, you cannot set vertical text alignment in a table style. The text will always be top-aligned when the table is created.
You also cannot set cell margins, column widths or row heights.
Amazing guide! You are my idol!!
A couple of questions:
– Where inside a PPTX or POTX container should I locate the tableStyles.xml file, and how should I reference it?
– If I define custom slides… will they be added to those that PowerPoint show by default? Can I override those?
Every PowerPoint file already has a tableStyles.xml part inside the ppt folder. You don’t have to add that part, you just need to add XML to it.
I’m not clear what you mean about adding custom slides. Perhaps you mean custom slide layouts. If you add custom slide layouts, they will be displayed as another layout choice when you click on the bottom half of the New Slide button.
Thanks for answering!! I will chime in to share my discovery in case it may help clarify the situation:
1. If you are starting a PPTX from scratch… there is no tableStyles.xml element inside the container… until you place your first table and save the document . This might be disconcerting. I was going crazy trying to retrofit a handmade tableStyles.xml into a PPTX. Just add the first table!
2. I wanted to say “Custom Table Styles” not “Custom Slides”. As you add tables in the PPTX using the standard table styles that appear in the Table Design menu, a new table definition … section appears. If you modify this definition… you will modify the Standard Table Definitions.
Sorry, your point # 1 is incorrect. As I replied earlier, “Every PowerPoint file already has a tableStyles.xml part inside the ppt folder. You don’t have to add that part, you just need to add XML to it.” You do not have to add a table to create the tableStyles.xml part.
I’m still not clear about your point #2. You cannot modify the Microsoft default table styles (I think that’s what you mean by “Standard Table Definitions”). Instead, when you create a custom table style, a new Custom row appears at the top of the Table Styles Gallery.