private Table CloneTable(Table table)
{
try
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
double widht = ConvertToCM(table.TableStyle.TableProperties.Width);
int rowCount = table.Rows.Count;
int columnCount = GetColumnCount(table);
Table clonedTable = CreateTextDocumentTable(
table.Document as TextDocument,
"generatedTable" + tableNumber,
table.StyleName,
rowCount,
columnCount,
widht,
table);
for (int i = 0; i < table.ColumnCollection.Count; i++)
{
clonedTable.ColumnCollection[i].ColumnStyle.ColumnProperties.Width =
table.ColumnCollection[i].ColumnStyle.ColumnProperties.Width;
}
for (int i1 = 0; i1 < table.Rows.Count; i1++)
{
Row row = clonedTable.Rows[i1];
Row clonedRow = CloneRow(table.Rows[i1], clonedTable);
for (int i = 0; i < row.Cells.Count; i++)
{
CopyCellContens(table.Rows[i1].Cells[i], row.Cells[i]);
}
}
return clonedTable;
}
catch (Exception e)
{
throw new ContentMockerException("Could not clone table", e);
}
}