Why are styles for the table first row being applied to additional rows?

Connor Shore 186 Reputation points
2021-06-21T16:52:47.157+00:00

I have 2 documents a template and then a document where data has been applied and generated. The issue is that there is a table with the the firstRow style having bold in it and then all additional rows are not bolded. This is correct in the template. However, when output is ran the style.xml still has only the firstRow having the bold property, but the document does not reflect that accurately, the entire table is bold.

Here is a picture of the template:
107648-image.png

Here is a picture of the output:
107715-image.png

The style element for the table is as follows (it is the same in the output and the template):

	<w:style w:type="table" w:customStyle="1" w:styleId="OWTable">  
		<w:name w:val="OW Table"/>  
		<w:basedOn w:val="TableNormal"/>  
		<w:rsid w:val="006D7790"/>  
		<w:pPr>  
			<w:spacing w:before="40" w:after="40" w:line="240" w:lineRule="auto"/>  
		</w:pPr>  
		<w:rPr>  
			<w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:cstheme="minorHAnsi"/>  
			<w:color w:val="000000" w:themeColor="text1"/>  
			<w:sz w:val="20"/>  
			<w:szCs w:val="24"/>  
			<w:lang w:val="en-US"/>  
		</w:rPr>  
		<w:tblPr>  
			<w:tblBorders>  
				<w:bottom w:val="single" w:sz="6" w:space="0" w:color="FFC000" w:themeColor="accent4"/>  
				<w:insideH w:val="single" w:sz="6" w:space="0" w:color="FFC000" w:themeColor="accent4"/>  
			</w:tblBorders>  
		</w:tblPr>  
		<w:trPr>  
			<w:tblHeader/>  
		</w:trPr>  
		<w:tblStylePr w:type="firstRow">  
			<w:pPr>  
				<w:spacing w:before="40" w:after="40" w:line="240" w:lineRule="auto"/>  
			</w:pPr>  
			<w:rPr>  
				<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"/>  
				<w:b/>  
				<w:i w:val="0"/>  
				<w:sz w:val="20"/>  
			</w:rPr>  
			<w:tblPr/>  
			<w:tcPr>  
				<w:vAlign w:val="bottom"/>  
			</w:tcPr>  
		</w:tblStylePr>  
	</w:style>  

If I comment out the <w:b/> line and save it, the output no longer is bolded on the 2nd row or the 1st row:

107610-image.png

Here is a link to the template and output documents to view inner xml's if needed: DOCUMENTS

Office Open Specifications
Office Open Specifications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Open Specifications: Technical documents for protocols, computer languages, standards support, and data portability. The goal with Open Specifications is to help developers open new opportunities to interoperate with Windows, SQL, Office, and SharePoint.
139 questions
{count} vote

Accepted answer
  1. Mike Bowen 1,781 Reputation points Microsoft Employee
    2021-07-13T19:14:43.127+00:00

    Hi @Connor Shore ,

    In the styles.xml part from output.docx there is a <w:trPr... element with a <w:tblHeader/> child element. This element should be in the header rows in the document.xml part. Adding it in the styles.xml applies the table header style to all rows, in this case bolding them.

    From ISO/IEC 29500-1:2016(E) 17.4.49 tblHeader (Repeat Table Row on Every New Page) :

    "This element specifies that the current table row shall be repeated at the top of each new page on which part of this table is displayed. This gives this table row the behavior of a 'header' row on each of these pages. This element can be applied to any number of rows at the top of the table structure in order to generate multi-row table headers."

    If you remove the <w:tblHeader/> element from the styles.xml part then only the first row will bold. If an <w:tblHeader/> element is then added as a child element of the <w:trPr... element for the first row (i.e. the header row) in the document.xml part then that row will repeat as a header row that matches the style and content of the header row on subsequent pages.

    Please let me know if that answers your question.

    -Mike


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.