﻿{% table results, 20, COLUMN_COUNT %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% item %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ cols[1].get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% enditem %}
</table>
{% endtable %}


{% set TABLE_ROW_COUNT = 20 %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% for row_index in range(TABLE_ROW_COUNT) %}
  {% set cols = [] %}
  {% set first_empty_col = (len(results) - row_index*COLUMN_COUNT) %}
  {% for col_index in range(COLUMN_COUNT) %}
  {% if row_index*COLUMN_COUNT+col_index < len(results) %}
  {% do cols.append(results[row_index*COLUMN_COUNT+col_index]) %}
  {% endif %}
  {% endfor %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ cols[1].get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% endfor %}
</table>






{% table results, 20 %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% item %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ row.get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% empty %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        {% if first_empty_row %}
        <span style="">以下空白</span>
        {% endif %}
      </p>
    </tc>
  </tr>
  {% enditem %}
{% endtable %}


{% set TABLE_ROW_COUNT = 20 %}
{% for result_index in range(TABLE_ROW_COUNT) %}
{% if result_index < len(results) %}
{% set row = results[result_index] %}
{% set row_index = result_index %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% if result_index < len(results) %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ row.get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% else %}
  {% set first_empty_row = result_index == len(results) %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        {% if first_empty_row %}
        <span style="">以下空白</span>
        {% endif %}
      </p>
    </tc>
  </tr>
  {% endif %}
{% endfor %}



{% page results, 20, COLUMN_COUNT %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% item %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ cols[1].get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% enditem %}
{% endpage %}


{% set PER_PAGE_RESULT_COUNT = 20 %}
{% for page_index in range( (len(results) + PER_PAGE_RESULT_COUNT*COLUMN_COUNT - 1) // (PER_PAGE_RESULT_COUNT*COLUMN_COUNT) ) %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% for row_index in range(PER_PAGE_RESULT_COUNT) %}
  {% set cols = [] %}
  {% set first_empty_col = (len(results) - page_index*PER_PAGE_RESULT_COUNT*COLUMN_COUNT - row_index*COLUMN_COUNT) %}
  {% for col_index in range(COLUMN_COUNT) %}
  {% set idx = page_index*PER_PAGE_RESULT_COUNT*COLUMN_COUNT + row_index*COLUMN_COUNT + col_index %}
  {% if idx < len(results) %}
  {% do cols.append(results[idx]) %}
  {% endif %}
  {% endfor %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ cols[1].get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% endfor %}
</table>
{% endfor %}


{% page results, 20 %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% item %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ row.get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% empty %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        {% if first_empty_row %}
        <span style="">以下空白</span>
        {% endif %}
      </p>
    </tc>
  </tr>
  {% enditem %}
{% endpage %}


{% set PER_PAGE_RESULT_COUNT = 20 %}
{% for page_index in  range( (len(results) + PER_PAGE_RESULT_COUNT - 1) // PER_PAGE_RESULT_COUNT) %}
<table>
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">姓名</span>
      </p>
    </tc>
  </tr>
  {% for result_index in range(PER_PAGE_RESULT_COUNT) %}
  {% set row_index = page_index*PER_PAGE_RESULT_COUNT + result_index %}
  {% if (page_index*PER_PAGE_RESULT_COUNT + result_index) < len(results) %}
  {% set row = results[page_index*PER_PAGE_RESULT_COUNT + result_index] %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        <span style="">{{ row.get('name') }}</span>
      </p>
    </tc>
  </tr>
  {% else %}
  {% set first_empty_row = (page_index*PER_PAGE_RESULT_COUNT + result_index) == len(results) %}
  <tr cant-split="1" height="1585">
    <tc align="center" span="3" width="1276">
      <p style="align:center;font-size:24">
        {% if first_empty_row %}
        <span style="">以下空白</span>
        {% endif %}
      </p>
    </tc>
  </tr>
  {% endif %}
  {% endfor %}
{% endfor %}
