Template:Get cell/doc
Appearance
![]() | This is a documentation subpage for Template:Get cell. It may contain usage information, categories and other content that is not part of the original template page. |
![]() | This template uses Lua: |
This template gets the content of a specified table cell. This is useful for making table cells whose value depend on others.
Usage
To get the content of a table cell, first you need to give an id to the table (see #Example). Then you can get the content of any cell in that table using the syntax:
{{Get cell| cell-reference | table-id }}
where "cell-reference" is something like A1, B2, D7, etc, and "table-id" is the id of the table (see #Example).
Notes:
- If the cell content is numeric, it will be automatically parsed into a plain number to simplify subsequent calculations (see #Example).
- If the table is transcluded into another page, use the third parameter of this template to specify the title or id of the original page.
Example
The following wikitext:
{| class="wikitable" id="population-table"
! Country
! Population
! Area
! Density
|-
| Argentina
| 45,773,884
| 2,796,427
| {{#expr: {{Get cell|B2|population-table}} / {{Get cell|B3|population-table}} round 0 }}
|-
| China
| 1,425,671,352
| 9,600,000
| {{#expr: {{Get cell|C2|population-table}} / {{Get cell|C3|population-table}} round 0 }}
|-
| United States
| 339,996,564
| 9,833,517
| {{#expr: {{Get cell|D2|population-table}} / {{Get cell|D3|population-table}} round 0 }}
|}
Will output the following table:
Country | Population | Area | Density |
---|---|---|---|
Argentina | 45,773,884 | 2,796,427 | 16 |
China | 1,425,671,352 | 9,600,000 | 149 |
United States | 339,996,564 | 9,833,517 | 35 |
Template data
This template gets the content of a specified table cell.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Cell reference | 1 | Cell to find
| String | required |
Table ID | 2 | ID of the table where the cell can be found
| String | required |
Page | 3 | Title or ID of the page where the cell can be found | Page name | optional |