class TableCreator
{
public void CreateAuxDocTable(Database db, Point3d insertionPoint, List<string> source)
{
Table tbl = new Table();
tbl.TableStyle = db.Tablestyle;
tbl.SetSize(source.Count, 1);
tbl.SetRowHeight(10);
tbl.Columns[0].Width = 55;
tbl.Position = insertionPoint;
for (int j = 0; j < source.Count; j++)
{
tbl.Cells[0, j].TextHeight = 4.5;
tbl.Cells[0, j].TextString = source[j];
tbl.Cells[0, j].Alignment = CellAlignment.MiddleCenter;
}
tbl.GenerateLayout();
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(tbl);
tr.AddNewlyCreatedDBObject(tbl, true);
tr.Commit();
}
}
}