Search code examples
ms-wordopenxml

Prevent Vertically Merged Cells from Breaking Across Pages


I would like to prevent vertically merged cells in tables that I generate from a word document template from breaking across pages programmatically using Office Open XML. I read here that I could add the properties "KeepNext" and "Keep Lines" to the paragraphs within the table cells that are vertically merged. However, if I apply the setting to the all of the rows in the table, the rows keep splitting when a new page is inserted in the formatting. All of the rows have the property "Allow row to break across pages" deselected. Here is the xml of one of the rows that gets splitted across pages.

<w:tr>
    <w:trPr>
      <w:cantSplit />
      <w:trHeight w:val="20" />
    </w:trPr>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="283" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>51</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="676" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>TARJETA DE CRÉDITO</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>REVOLVENTE</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>INDIVIDUAL</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>BANCO</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="283" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>MX</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>08/12/2012</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>20/10/2009</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>14/11/2012</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="709" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>02/05/2012</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>14/11/2012</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="425" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t />
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>8000</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>10706</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>0</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="576" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>6799</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="558" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t />
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="567" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>0</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>PAGO MINIMO</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="671" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>97=CUENTA CON DEUDA PARCIAL O TOTAL SIN RECUPERAR</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="547" w:type="dxa" />
        <w:vMerge w:val="restart" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>05</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>31/10/2012</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>3296</w:t>
        </w:r>
      </w:p>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="547" w:type="dxa" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>2012</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="547" w:type="dxa" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>2011</w:t>
        </w:r>
      </w:p>
    </w:tc>
    <w:tc>
      <w:tcPr>
        <w:tcW w:w="523" w:type="dxa" />
        <w:vAlign w:val="center" />
      </w:tcPr>
      <w:p>
        <w:pPr>
          <w:jc w:val="center" />
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
        </w:pPr>
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
            <w:sz w:val="6" />
            <w:szCs w:val="6" />
            <w:lang w:val="es-ES" />
          </w:rPr>
          <w:t>2010</w:t>
        </w:r>
      </w:p>
    </w:tc>
  </w:tr>

This is the result that I get so far:

enter image description here

However, this is what I would like to get (eventually).

enter image description here

Let me know if I can add more helpful information, as I am running out of words.


Solution

  • Do NOT apply KeepNext to the LAST paragraph in a table cell. That will allow Word to break the page at the end of a row.

    The most efficient way would be a pair of styles for the paragraphs in the table, one with KeepNext the other without. All the formatting that repeats itself for every cell (w:pPr and w:rPr) in the sample you show us would then be unnecessary: less code for you to write and smaller file size!