using var db = Application.DocumentManager.MdiActiveDocument.Database;
using var tr = db.TransactionManager.StartTransaction();
var table = new Table();
var standardTableStyle = tr.GetObject(db.TableStyle, OpenMode.ForRead);
table.TableStyle = standardTableStyle.ObjectId;
table.Rows[0].Style = "_TITLE";
table.Rows[1].Style = "_HEADER";
table.Rows[2].Style = "_DATA";
table.Rows[0].Style = "_HEADER";
table.Rows[1].Style = "_DATA";
table.Rows[0].Style = "_TITLE";
table.Rows[1].Style = "_DATA";
table.Rows[0].Style = "_DATA";
table.Rows[1].Style = "_DATA";
注意:
- 必须先设置TableStyle才能设置Rows.Style,否则会报eNotApplicable错误
- 在访问Rows[1]、Rows[2]之前,需要保证Rows[1]、Rows[2]不会OutOfRange(比如先填充数据再访问Rows[1],Rows[2]或其他可行的方式)