private int GetColumnCount(Table table) { int columnCount = 0; foreach (Row row in table.Rows) { if (row.Cells.Count > columnCount) columnCount = row.Cells.Count; } return columnCount; }