public static Table CreateTextDocumentTable(
AODL.Document.TextDocuments.TextDocument document,
string tableName,
string styleName,
int rows,
int columns,
double width,
bool useTableRowHeader,
bool useBorder)
{
string tableCnt = document.DocumentMetadata.TableCount.ToString();
Table table = new Table(document, tableName, styleName);
table.TableStyle.TableProperties.Width = width.ToString().Replace(",",".")+"cm";
for(int i=0; i<columns; i++)
{
Column column = new Column(table, "co"+tableCnt+i.ToString());
column.ColumnStyle.ColumnProperties.Width = GetColumnCellWidth(columns, width);
table.ColumnCollection.Add(column);
}
if (useTableRowHeader)
{
rows--;
RowHeader rowHeader = new RowHeader(table);
Row row = new Row(table, "roh1"+tableCnt);
for(int i=0; i<columns; i++)
{
Cell cell = new Cell(table.Document, "rohce"+tableCnt+i.ToString());
if (useBorder)
cell.CellStyle.CellProperties.Border = Border.NormalSolid;
row.Cells.Add(cell);
}
rowHeader.RowCollection.Add(row);
table.RowHeader = rowHeader;
}
for(int ir=0; ir<rows; ir++)
{
Row row = new Row(table, "ro"+tableCnt+ir.ToString());
for(int ic=0; ic<columns; ic++)
{
Cell cell = new Cell(table.Document, "ce"+tableCnt+ir.ToString()+ic.ToString());
if (useBorder)
cell.CellStyle.CellProperties.Border = Border.NormalSolid;
row.Cells.Add(cell);
}
table.Rows.Add(row);
}
return table;
}