How to update a table in the header of a document

Hi there,
I have a document template that I’m updating with Aspose.Words. for .NET. The template contains 20 tables of KPI / dashboard data. I update each table in the document with the following code snipet example:

t = 0;
lastCol = 8;

rowDescription = "Total AOT";

Table table = doc.FirstSection.Body.Tables[t];
if(item.GetValue("RowDescription").ToString() == rowDescription)
{
    r = 2;
    c = 1;

    while (c<=lastCol)
    {
      colName = "Col" + c.ToString();

      cellValue = item.GetValue(colName).ToString();
      table.Rows[r].Cells[c].FirstParagraph.AppendChild(new Run(doc,cellValue));

      c += 1;
    }

}

this approach works fine for updating each table in the document body.

Can you please provide an example of how to refer to the first row, second cell of the only table in the document header.

I guess it’s this line that needs the correct syntax when referring to a table in the header:
Table table = doc.FirstSection.Body.Tables[t];

@len.wright You can use the following code to get the first table in the document’s header:

Document doc = new Document(@"C:\Temp\in.docx");
// Get the section.
Section section = doc.Sections[0];
// Get header or footer
HeaderFooter hf = section.HeadersFooters[HeaderFooterType.HeaderPrimary];
// Get the first table in the header.
Table table = (Table)hf.GetChild(NodeType.Table, 0, true);