<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://the.satanic.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATablebuilder</id>
	<title>Module:Tablebuilder - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://the.satanic.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATablebuilder"/>
	<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Tablebuilder&amp;action=history"/>
	<updated>2026-04-20T06:15:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://the.satanic.wiki/index.php?title=Module:Tablebuilder&amp;diff=10958&amp;oldid=prev</id>
		<title>WikiGOD: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Tablebuilder&amp;diff=10958&amp;oldid=prev"/>
		<updated>2021-04-30T02:24:03Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:24, 30 April 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key zzegtzyr_mw19226-mwjf_:diff:1.41:old-10957:rev-10958 --&gt;
&lt;/table&gt;</summary>
		<author><name>WikiGOD</name></author>
	</entry>
	<entry>
		<id>https://the.satanic.wiki/index.php?title=Module:Tablebuilder&amp;diff=10957&amp;oldid=prev</id>
		<title>Mediawiki&gt;KockaAdmiralac: nowiki</title>
		<link rel="alternate" type="text/html" href="https://the.satanic.wiki/index.php?title=Module:Tablebuilder&amp;diff=10957&amp;oldid=prev"/>
		<updated>2017-02-10T17:18:10Z</updated>

		<summary type="html">&lt;p&gt;nowiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--|Creates a new html table using the functions and mw.html library&lt;br /&gt;
---Variables prefixed with h are mw.html nodes. e.g. hTable is created using mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
local tableModel = {}&lt;br /&gt;
local libraryUtil = require( &amp;#039;libraryUtil&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
-- //Lazy load methods&lt;br /&gt;
local createCol,appendRow,appendCol,createRow&lt;br /&gt;
&lt;br /&gt;
--% Creates  table model&lt;br /&gt;
--@  arrTable (table) A Two dimensional array of the table ,e.g. {{&amp;#039;header&amp;#039;,&amp;#039;header2&amp;#039;},{&amp;quot;cell1&amp;quot;,&amp;quot;cell2&amp;quot;}}&lt;br /&gt;
--@ sTableDescription (string) Caption of the table (e.g.&amp;quot;green&amp;quot;)&lt;br /&gt;
--@ sStyle (string) Table style ( e.g. sStyle=&amp;quot;color:green&amp;quot;)&lt;br /&gt;
--@ tClass (table)- Table classes (e.g. {&amp;quot;wikitable&amp;quot;,&amp;quot;sortable&amp;quot;})&lt;br /&gt;
--: (table) a tablemodel &amp;quot;class&amp;quot; that allows users to create tables &lt;br /&gt;
function tableModel.new(arrExtData,sTableDescription, sStyle,tClass)&lt;br /&gt;
    local  self = {} &lt;br /&gt;
    local checkSelf = libraryUtil.makeCheckSelfFunction( &amp;#039;tableModel&amp;#039;, &amp;#039;obj&amp;#039;, self, &amp;#039;tableModel object&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
    self.tableFormatting = {caption=&amp;quot;&amp;quot;,class={},style=&amp;quot;&amp;quot;}&lt;br /&gt;
    self.arrTable =  {}&lt;br /&gt;
&lt;br /&gt;
    --% Outputs the attributes of a html table&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number) Column number&lt;br /&gt;
    --: (table) attributes for a specific cell (row + col)&lt;br /&gt;
    function self:getAttribs(iRow, iCol)&lt;br /&gt;
        checkSelf(self,&amp;quot;getAttribs&amp;quot;)&lt;br /&gt;
        if (self.arrTable[iRow] and self.arrTable[iRow][iCol]) then&lt;br /&gt;
            return self.arrTable[iRow][iCol]&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets an attribute to a cell&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number) Column number&lt;br /&gt;
    --@ oCellAttributes (table) Attributes to be set, a single string attribute  or many as a table &lt;br /&gt;
    --@ oAttrVal (string) attribute to be set&lt;br /&gt;
    function self:setCellAttr(iRow,iCol, oCellAttributes, oAttrVal)&lt;br /&gt;
        checkSelf(self,&amp;quot;setCellAttr&amp;quot;)&lt;br /&gt;
        if (self.arrTable[iRow] and self.arrTable[iRow][iCol]  ) then&lt;br /&gt;
            local oTableData = self:getAttribs(iRow,iCol)&lt;br /&gt;
            local sCellVal = oTableData.sValue&lt;br /&gt;
            &lt;br /&gt;
            if  oCellAttributes and type (oCellAttributes)==&amp;quot;string&amp;quot; then&lt;br /&gt;
                oTableData.oFormatting = {[oCellAttributes]=oAttrVal}&lt;br /&gt;
            end&lt;br /&gt;
        &lt;br /&gt;
            if (type(oCellAttributes)==&amp;quot;table&amp;quot; and  next(oCellAttributes)) then&lt;br /&gt;
                oTableData.oFormatting = oCellAttributes&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets a value to a cell	&lt;br /&gt;
    --@ sValue (string) Value to be set to a table&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number)  Column number&lt;br /&gt;
    --@ formatting (table) Formatting to be set, e.g. {&amp;quot;style&amp;quot;=&amp;quot;color:red&amp;quot;}&lt;br /&gt;
    --@ header (boolean) Sets this cell to a header  (true to set, false to remove)&lt;br /&gt;
    function self:setCell (sValue,iRow,iCol,oFormatting,bHeader)&lt;br /&gt;
        checkSelf(self,&amp;quot;setCell&amp;quot;)&lt;br /&gt;
        if self.arrTable[iRow] and (self.arrTable[iRow][iCol]) then&lt;br /&gt;
            local oTableData = self:getAttribs(iRow,iCol)&lt;br /&gt;
            oTableData.sValue = sValue&lt;br /&gt;
            oTableData.bHeader = bHeader&lt;br /&gt;
            &lt;br /&gt;
            if (not(self.arrTable[iRow][&amp;quot;rowdata&amp;quot;])) then&lt;br /&gt;
                self.arrTable[iRow][&amp;quot;rowdata&amp;quot;]={}&lt;br /&gt;
            end&lt;br /&gt;
            self:setCellAttr(iRow,iCol,oFormatting)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Imports a lua table, changes it to an html table&lt;br /&gt;
    --@ arrInput (table) Table two dimensional (e.g. {{&amp;#039;f&amp;#039;,&amp;#039;z&amp;#039;}})&lt;br /&gt;
    function self:setTable(arrInput)&lt;br /&gt;
        checkSelf(self,&amp;quot;setTable&amp;quot;)&lt;br /&gt;
        local bHeader &lt;br /&gt;
        &lt;br /&gt;
        if arrInput and type(arrInput) ==&amp;quot;table&amp;quot; then&lt;br /&gt;
            for iRow,tCols in pairs(arrInput) do&lt;br /&gt;
                &lt;br /&gt;
                if type(tCols)==&amp;quot;table&amp;quot; then&lt;br /&gt;
                    self.arrTable[iRow] = {}&lt;br /&gt;
                    for iCol,sValue in ipairs(tCols) do&lt;br /&gt;
                        bHeader = (iRow==1)&lt;br /&gt;
                        self.arrTable[iRow][iCol]={}&lt;br /&gt;
                        self:setCell (sValue,iRow,iCol,{},bHeader)&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    bHeader = true&lt;br /&gt;
                    self.arrTable[1] = self.arrTable[1] or {}&lt;br /&gt;
                    local iCol = #self.arrTable[1]+1&lt;br /&gt;
                    self.arrTable[1][iCol] = {}&lt;br /&gt;
                    self:setCell (tCols,1,iCol,{},bHeader)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    --% Sets data to a cell &lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number) Column number&lt;br /&gt;
    --@ sField (string) internal table field to set data&lt;br /&gt;
    --@ sNewValue (string) new value&lt;br /&gt;
    function self:setData(iRow,iCol,sField, sNewValue)&lt;br /&gt;
        checkSelf(self,&amp;quot;setData&amp;quot;)&lt;br /&gt;
        if (self.arrTable[iRow] and self.arrTable[iRow][iCol]&lt;br /&gt;
            and self.arrTable[iRow][iCol][sField]) then&lt;br /&gt;
            local arrMetaData = self.arrTable[iRow][iCol]&lt;br /&gt;
            arrMetaData[sField] = sNewValue&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Gets a cell from a table&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number)  Column number&lt;br /&gt;
    --: (table) attributes for a specific cell (row + col)&lt;br /&gt;
    function self:getCell(iRow,iCol)&lt;br /&gt;
        checkSelf(self,&amp;quot;getCell&amp;quot;)&lt;br /&gt;
        if self.arrTable[iRow] and self.arrTable[iRow][iCol] then  &lt;br /&gt;
            return self.arrTable[iRow][iCol].sValue&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets the style of a cell&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number)  Column number&lt;br /&gt;
    --@ sCellStyle (string) Cell style, e.g. (&amp;quot;color&amp;quot;)&lt;br /&gt;
    --@ sAttrVal (string) Cell attribute, e.g. (&amp;quot;blue&amp;quot;)&lt;br /&gt;
    function self:setCellStyle(iRow,iCol,sCellStyle,sAttrVal)&lt;br /&gt;
        self:setCellAttr(iRow,iCol,sCellStyle,sAttrVal)&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets a cell as a header&lt;br /&gt;
    --@ iRow (number) Row number&lt;br /&gt;
    --@ iCol (number) Column number&lt;br /&gt;
    --@ bHeader (boolean) true if header&lt;br /&gt;
    function self:setCellHeader(iRow,iCol,bHeader)&lt;br /&gt;
        checkSelf(self,&amp;quot;setCellHeader&amp;quot;)&lt;br /&gt;
        if self.arrTable[iRow] and self.arrTable[iRow][iCol] then&lt;br /&gt;
            local oTableData = self:getAttribs(iRow,iCol)&lt;br /&gt;
            local sCellVal =  oTableData.sValue      &lt;br /&gt;
            &lt;br /&gt;
            if (type(bHeader)==&amp;quot;boolean&amp;quot;) then&lt;br /&gt;
                oTableData[&amp;quot;bHeader&amp;quot;] =  bHeader&lt;br /&gt;
            end &lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    --% Creates a row &lt;br /&gt;
    --@ tFormatting (string) Formatting to be set, e.g. {&amp;quot;style&amp;quot;=&amp;quot;color:red&amp;quot;}.)&lt;br /&gt;
    --: (table) A mw.html node containing a row&lt;br /&gt;
    function createRow(tFormatting)&lt;br /&gt;
        local hTableRow= mw.html.create(&amp;#039;tr&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
        if(tFormatting and type(tFormatting)==&amp;quot;table&amp;quot; and next(tFormatting)) then&lt;br /&gt;
            hTableRow:attr(tFormatting)&lt;br /&gt;
            hTableRow:node(sHeadingCol) &lt;br /&gt;
        end&lt;br /&gt;
        hTableRow:done()&lt;br /&gt;
        &lt;br /&gt;
        return hTableRow&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    --% Appends a row to a table &lt;br /&gt;
    --@ hTable (table) hTable mw.html table node --e.g. mw.html.create(&amp;#039;table&amp;#039;)) &lt;br /&gt;
    --@ tFormatting (table)  {[&amp;quot;style&amp;quot;]=&amp;quot;color:green&amp;quot;}&lt;br /&gt;
    --: (table) A full mw.html table &lt;br /&gt;
    function appendRow(hTable, hRow,tFormatting)&lt;br /&gt;
        if(tFormatting and type(tFormatting)==&amp;quot;table&amp;quot; and next(tFormatting)) then&lt;br /&gt;
               hRow:attr(tFormatting)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if (hRow) and  (hTable) then&lt;br /&gt;
            hTable:node(hRow)&lt;br /&gt;
        else &lt;br /&gt;
           return &amp;quot;Syntax error: Row and table cannot be nil!&amp;quot;  &lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        return hTable:done()&lt;br /&gt;
    end &lt;br /&gt;
    &lt;br /&gt;
    --% Creates a new column &lt;br /&gt;
    --@ sColValue (string) Value of table column&lt;br /&gt;
    --@ tFormatting (table) Formatting to be set, e.g. {&amp;quot;style&amp;quot;=&amp;quot;color:red&amp;quot;}.&lt;br /&gt;
    --@ bHeader (boolean) Returns true if header&lt;br /&gt;
    --: (table) A full mw.html node containing a &amp;quot;td&amp;quot;&lt;br /&gt;
    function createCol(sColValue,tFormatting,bHeader)&lt;br /&gt;
        local sTagCol = &amp;quot;td&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        if (bHeader) then &lt;br /&gt;
            sTagCol =&amp;quot;th&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        local hHeadingCol =mw.html.create(sTagCol)&lt;br /&gt;
        if  (sColValue and type(sColValue)==&amp;quot;string&amp;quot;) or  sColValue ==&amp;quot;&amp;quot; or type(sColValue)==&amp;quot;number&amp;quot;  then&lt;br /&gt;
            hHeadingCol:wikitext(sColValue)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if (tFormatting and type(tFormatting)==&amp;quot;table&amp;quot;) then&lt;br /&gt;
            local sAttribute, sValues = next(tFormatting)&lt;br /&gt;
             if (type(sAttribute)==&amp;quot;string&amp;quot; and sValues) then &lt;br /&gt;
                hHeadingCol :attr(tFormatting )&lt;br /&gt;
             else&lt;br /&gt;
                if (sAttribute) then&lt;br /&gt;
                    return &amp;quot;Error: Attributes need Key and value ({[key]=&amp;#039;value&amp;#039;}), e.g. {[&amp;#039;style&amp;#039;]=&amp;#039;color:blue&amp;#039;}&amp;quot;&lt;br /&gt;
                end&lt;br /&gt;
             end&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        hHeadingCol:done()&lt;br /&gt;
        return hHeadingCol&lt;br /&gt;
    end&lt;br /&gt;
    --% Appends a column cell to a row &lt;br /&gt;
    --@ hColumn (table) A mw.html node containing a column (html th)&lt;br /&gt;
    --@ hTableRow (table) A mw.html node containing a cell (html td)&lt;br /&gt;
    --@ tFormatting (table) Formatting to be set, e.g. {&amp;quot;style&amp;quot;=&amp;quot;color:red&amp;quot;}.&lt;br /&gt;
    --: (string) An error if the table is invalid or nil if not&lt;br /&gt;
    function appendCol(hTableRow,hColumn,tFormatting)&lt;br /&gt;
        local sColType = type (hColumn)&lt;br /&gt;
        &lt;br /&gt;
        if sColType ==&amp;quot;string&amp;quot; or  sColType ==&amp;quot;number&amp;quot; or  sColType ==&amp;quot;boolean&amp;quot; then&lt;br /&gt;
            hColumn = createCol(hColumn)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if(tFormatting and type(tFormatting)==&amp;quot;table&amp;quot; and next(tFormatting)) then&lt;br /&gt;
            local sAttribute, sValues = next(tFormatting)&lt;br /&gt;
            if (type(sAttribute)==&amp;quot;string&amp;quot; and sValues) then &lt;br /&gt;
                hHeadingCol :attr(tFormatting )&lt;br /&gt;
            else&lt;br /&gt;
                if (sAttribute) then&lt;br /&gt;
                    return &amp;quot;Error: Attributes need Key and value ({[key]=&amp;#039;value&amp;#039;}), e.g. {[&amp;#039;style&amp;#039;]=&amp;#039;color:blue&amp;#039;}&amp;quot;&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if (hTableRow and hColumn and type(hColumn)==&amp;quot;table&amp;quot; ) then&lt;br /&gt;
            hTableRow = hTableRow:node(hColumn)&lt;br /&gt;
        else &lt;br /&gt;
           return &amp;quot;Syntax error: Table row and table column cannot be nil!&amp;quot;  &lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Outputs the html table&lt;br /&gt;
    --: (table) An mw.html node containing the whole table&lt;br /&gt;
    function self:getTable ()&lt;br /&gt;
        checkSelf(self,&amp;quot;getTable&amp;quot;)&lt;br /&gt;
        local hRow,hCell &lt;br /&gt;
        local hTable = mw.html.create(&amp;quot;table&amp;quot;)&lt;br /&gt;
        hTable:tag(&amp;quot;caption&amp;quot;)&lt;br /&gt;
            :wikitext(self.tableFormatting.caption)&lt;br /&gt;
        hTable:cssText(self.tableFormatting.style)&lt;br /&gt;
        &lt;br /&gt;
        for i,sClassName in pairs(self.tableFormatting.class) do&lt;br /&gt;
            if type(sClassName) == &amp;quot;string&amp;quot; then&lt;br /&gt;
                hTable:addClass(sClassName)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        for iRow,tRow in pairs(self.arrTable) do&lt;br /&gt;
            if (self.arrTable[iRow]) then&lt;br /&gt;
                tRowFormat = self.arrTable[iRow][&amp;quot;rowdata&amp;quot;] &lt;br /&gt;
            end&lt;br /&gt;
            hRow = createRow(tRowFormat)&lt;br /&gt;
            &lt;br /&gt;
            for iCol,oCell in ipairs(tRow)  do&lt;br /&gt;
                if (oCell) then&lt;br /&gt;
                    hCell = createCol(oCell.sValue,oCell.oFormatting,oCell.bHeader)&lt;br /&gt;
                    appendCol(hRow,hCell)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
            appendRow(hTable, hRow)&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        return hTable:done()&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets the rows and columns of table&lt;br /&gt;
    --iRows (number) Number of rows in the table&lt;br /&gt;
    --iColumns (number) Number of columns in the table&lt;br /&gt;
    function self:setGrid(iRows,iColumns)&lt;br /&gt;
        checkSelf(self,&amp;quot;setGrid&amp;quot;)&lt;br /&gt;
        local bHeader&lt;br /&gt;
&lt;br /&gt;
        for iRowCount=0,iRows  do&lt;br /&gt;
            self.arrTable[iRowCount] = {}&lt;br /&gt;
            bHeader = false&lt;br /&gt;
            for iColCount=0, iColumns do&lt;br /&gt;
                bHeader = (iRowCount==1)&lt;br /&gt;
                self.arrTable[iRowCount][iColCount] ={[&amp;quot;sValue&amp;quot;]= &amp;quot;&amp;quot;,[&amp;quot;oFormatting&amp;quot;] =  {},[&amp;quot;bHeader&amp;quot;] =  bHeader}&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Prints out text representation of the table&lt;br /&gt;
    --: (string) text representation of the table&lt;br /&gt;
    function self:getGrid()&lt;br /&gt;
        checkSelf(self,&amp;quot;getGrid&amp;quot;)&lt;br /&gt;
        local sGrid  = &amp;quot;\tCol1\tCol2\n&amp;quot;&lt;br /&gt;
        local sValue &lt;br /&gt;
        for iRow =1,#self.arrTable do&lt;br /&gt;
            sGrid = sGrid ..iRow..&amp;quot;\t|&amp;quot;&lt;br /&gt;
            for iCol =1, #self.arrTable[iRow] do&lt;br /&gt;
                sValue = self:getCell(iRow,iCol) or &amp;quot;&amp;quot;&lt;br /&gt;
                sGrid = sGrid ..&amp;quot;\t&amp;quot; .. sValue .. &amp;quot;\t|&amp;quot;&lt;br /&gt;
            end&lt;br /&gt;
            sGrid = sGrid ..&amp;quot;\n&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
        return sGrid&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets the styling of a table&lt;br /&gt;
    --@ sTableDescription (string) Description or caption of the table&lt;br /&gt;
    --@ sStyle (string) the styles (e.g. &amp;quot;color:green&amp;quot;)&lt;br /&gt;
    --@ tClass  (table) the css classes the table will use (e.g.{&amp;quot;bluetable&amp;quot;,&amp;quot;greentext&amp;quot;}&lt;br /&gt;
    function self:setTableFormat(sTableDescription, sStyle,tClass)&lt;br /&gt;
        checkSelf(self,&amp;quot;setTableFormat&amp;quot;)&lt;br /&gt;
        if sTableDescription and type(sTableDescription)==&amp;quot;string&amp;quot;  then&lt;br /&gt;
              self.tableFormatting.caption = sTableDescription&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if (tClass) then&lt;br /&gt;
            if type(tClass)==&amp;quot;table&amp;quot; and next(tClass) then  &lt;br /&gt;
                self.tableFormatting.class= tClass&lt;br /&gt;
            end&lt;br /&gt;
        end &lt;br /&gt;
    &lt;br /&gt;
        if(sStyle and  type(sStyle)==&amp;quot;string&amp;quot; and sStyle~=&amp;quot;&amp;quot;) then&lt;br /&gt;
            self.tableFormatting.style =sStyle&lt;br /&gt;
        end&lt;br /&gt;
       &lt;br /&gt;
    end &lt;br /&gt;
    --% Sets the formatting of a table&lt;br /&gt;
    --@ iRow (number) The row to add the styling&lt;br /&gt;
    --@ tFormatting (table) Formatting to be set, e.g. {&amp;quot;style&amp;quot;=&amp;quot;color:red&amp;quot;}.&lt;br /&gt;
    function self:setRowFormat(iRow,tFormatting)&lt;br /&gt;
        checkSelf(self,&amp;quot;setRowFormat&amp;quot;)&lt;br /&gt;
        if (iRow and  self.arrTable[iRow] and self.arrTable[iRow][&amp;quot;rowdata&amp;quot;]) then&lt;br /&gt;
            self.arrTable[iRow][&amp;quot;rowdata&amp;quot;] = tFormatting&lt;br /&gt;
        end&lt;br /&gt;
    end &lt;br /&gt;
    --% Adds a new row to a table&lt;br /&gt;
    --@ iRow (number)  The index of the row to add&lt;br /&gt;
    function self:addRow(iRow)&lt;br /&gt;
        checkSelf(self,&amp;quot;addRow&amp;quot;)&lt;br /&gt;
        local sValue =&amp;quot;&amp;quot;&lt;br /&gt;
        local tColumns ={}&lt;br /&gt;
        local iRowToAdd = tonumber(iRow) or 1&lt;br /&gt;
        &lt;br /&gt;
        if iRow and (iRow&amp;gt;=(#self.arrTable +2) or iRow&amp;lt;1) then&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        if self.arrTable and self.arrTable[1]  then&lt;br /&gt;
            iRowToAdd = iRow or #self.arrTable+1&lt;br /&gt;
             for i=1,#self.arrTable[1] do&lt;br /&gt;
                tColumns[i] = {}&lt;br /&gt;
             end&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(self.arrTable,iRowToAdd,tColumns)&lt;br /&gt;
    end&lt;br /&gt;
    --% Removes a row from the table	&lt;br /&gt;
    --@ iRow (number) The index of the row to remove&lt;br /&gt;
    function self:removeRow(iRow)&lt;br /&gt;
        checkSelf(self,&amp;quot;removeRow&amp;quot;)&lt;br /&gt;
        if self.arrTable[iRow] then&lt;br /&gt;
            table.remove(self.arrTable,iRow)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Sets the contents of a row&lt;br /&gt;
    --@ iRow (number) The index of the row to set&lt;br /&gt;
    --@ tTable (table) contents (e.g. {2,3})&lt;br /&gt;
    function self:setRow(iRow,tTable)&lt;br /&gt;
        checkSelf(self,&amp;quot;setRow&amp;quot;)&lt;br /&gt;
        if iRow and self.arrTable[iRow] and tTable then&lt;br /&gt;
            for iCol,sValue in pairs(tTable) do&lt;br /&gt;
                self:setCell(sValue,iRow,iCol)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
   &lt;br /&gt;
    --% Adds a new column to the table&lt;br /&gt;
    --@ sColName(string) Name of the column&lt;br /&gt;
    --@ iCol (number) The index of the column to set&lt;br /&gt;
    function self:addCol(sColName,iCol)&lt;br /&gt;
        checkSelf(self,&amp;quot;addCol&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        if iCol and self.arrTable &lt;br /&gt;
            and self.arrTable[1]&lt;br /&gt;
            and (iCol&amp;gt;=#self.arrTable[1] +2 or  iCol&amp;lt;1) then&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if self.arrTable and self.arrTable[1] and not(iCol) then&lt;br /&gt;
            iCol = #self.arrTable[1]+1&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if self.arrTable[1] then &lt;br /&gt;
            table.insert(self.arrTable[1],iCol,{})&lt;br /&gt;
            self:setCell(sColName,1,iCol,{},true)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    --% Removes a new column to the table&lt;br /&gt;
    --@ iCol (number) The index of the column to remove&lt;br /&gt;
    function self:removeCol(iCol)&lt;br /&gt;
        checkSelf(self,&amp;quot;removeCol&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        if iCol then&lt;br /&gt;
            for i,v in pairs(self.arrTable) do&lt;br /&gt;
                if self.arrTable[i] and self.arrTable[i][iCol] then&lt;br /&gt;
                    table.remove(self.arrTable[i],iCol)&lt;br /&gt;
                end    &lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    --% Gets number of rows in table&lt;br /&gt;
    --: (number) Number of rows&lt;br /&gt;
    function self:getRowCount()&lt;br /&gt;
        checkSelf(self,&amp;quot;getRowCount&amp;quot;)&lt;br /&gt;
        return #self.arrTable&lt;br /&gt;
    end&lt;br /&gt;
    --% Gets number of columns in table&lt;br /&gt;
    --: (number) Number of columns&lt;br /&gt;
    function self:getColCount(iRow)&lt;br /&gt;
        checkSelf(self,&amp;quot;getColCount&amp;quot;)&lt;br /&gt;
        iRow = iRow or 1&lt;br /&gt;
        if self.arrTable[iRow] then&lt;br /&gt;
            return #self.arrTable[iRow]&lt;br /&gt;
        end&lt;br /&gt;
        return 0&lt;br /&gt;
    end&lt;br /&gt;
    --% Initializes the tablebuilder (internal use)&lt;br /&gt;
    function initialize()&lt;br /&gt;
        self.setTableFormat(self,sTableDescription, sStyle,tClass)&lt;br /&gt;
        self:setTable(arrExtData)&lt;br /&gt;
    end&lt;br /&gt;
    -- //Constructor &lt;br /&gt;
    initialize()&lt;br /&gt;
    &lt;br /&gt;
    return self&lt;br /&gt;
end&lt;br /&gt;
--%  Create a new table builder &lt;br /&gt;
--@ arrExtData (table) A two dimensional array containing a table e.g {{&amp;quot;Girls&amp;quot;,&amp;quot;Boys&amp;quot;},{&amp;quot;Xena&amp;quot;,&amp;quot;Hercules&amp;quot;}}&lt;br /&gt;
--@ sTableDescription (string) A caption for the table  e.g. &amp;quot;Table of boys and girls&lt;br /&gt;
--@ sStyle (string) Basic styling for the table  e.g. &amp;quot;background:green&amp;quot;&lt;br /&gt;
--@ tClass (table) CSS classes for the whole table e.g. {&amp;quot;boysandgirls&amp;quot;,&amp;quot;red&amp;quot;}&lt;br /&gt;
function p.new(arrExtData,sTableDescription, sStyle,tClass)&lt;br /&gt;
    return tableModel.new(arrExtData,sTableDescription, sStyle,tClass)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Test code&lt;br /&gt;
function p.test(frame)&lt;br /&gt;
    -- Array consisting of rows and columns&lt;br /&gt;
    local tRowData = {&lt;br /&gt;
    -- Row Columns&lt;br /&gt;
        {&amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;},&lt;br /&gt;
        {&amp;quot;44&amp;quot;,&amp;quot;3&amp;quot;}, &lt;br /&gt;
        {&amp;quot;6&amp;quot;,&amp;quot;8&amp;quot;}, &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local c = tableModel.new(tRowData,&amp;quot;Table&amp;quot;,&amp;quot;&amp;quot;,{&amp;quot;wikitable&amp;quot;})&lt;br /&gt;
    local row1 = 4&lt;br /&gt;
    local col1 = 1&lt;br /&gt;
    local celltext = &amp;quot;green&amp;quot;&lt;br /&gt;
    local cellFormat = {[&amp;quot;style&amp;quot;]=&amp;quot;color:green&amp;quot;}&lt;br /&gt;
    &lt;br /&gt;
    c:addRow()&lt;br /&gt;
    c:setCell(&amp;quot;7&amp;quot;,row1,col1)&lt;br /&gt;
    c:setCell(&amp;quot;2&amp;quot;,row1,2)&lt;br /&gt;
    &lt;br /&gt;
    local row2 = 1&lt;br /&gt;
    local col2 = 1&lt;br /&gt;
    &lt;br /&gt;
    c:setCell(celltext,row2,col2,cellFormat)&lt;br /&gt;
    &lt;br /&gt;
    return c:getTable()&lt;br /&gt;
end&lt;br /&gt;
-- End Test code&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Mediawiki&gt;KockaAdmiralac</name></author>
	</entry>
</feed>