我有一个充满书签的单词模板,但是在尝试插入表格时我被卡住了...首先我收到了一个 COMException 说请求的集合成员不存在..我认为这意味着书签是set 的名称与我现在的表名称不同..无论如何,表格根本不显示..我在数据输入表格之前设置了格式...
像这样:
// Insert Table
Word.Table tbl1 = this.Tables[1];
Tables.Add(Range: tbl1.Range, NumColumns: 2, NumRows: 2);
tbl1.Range.Font.Size = 10;
tbl1.Range.Font.Name = "Georgia";
tbl1.Range.Font.Bold.Equals(true);
tbl1.Range.Font.ColorIndex = Word.WdColorIndex.wdBlue;
tbl1.Range.Cells.Shading.Texture = Word.WdTextureIndex.wdTexture10Percent;
tbl1.Range.Cells.Shading.BackgroundPatternColorIndex = Word.WdColorIndex.wdBlue;
tbl1.Range.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
tbl1.Rows.SetHeight(RowHeight: 24, HeightRule: Word.WdRowHeightRule.wdRowHeightAtLeast);
tbl1.Columns[1].SetWidth(ColumnWidth: 170, RulerStyle: Word.WdRulerStyle.wdAdjustNone);
tbl1.Columns[2].SetWidth(ColumnWidth: 310, RulerStyle: Word.WdRulerStyle.wdAdjustNone);
tbl1.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
tbl1.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleNone;
// end of table insert
然后填充表格的代码在......
if (multipleLimits.Equals(false))
{
tbl1.Cell(1, 1).Range.Text = "Indemnity Limit:";
}
else
{
tbl1.Cell(1, 1).Range.Text = IndemlimitsText(iIndemnLimit).ToString();
}
switch (typeOfInsID)
{
case "4":
tbl1.Cell(1, 1).Range.Text = "Public/Products Liability:";
break;
}
tbl1.Cell(2, 1).Range.Text = "Excess:";
if (multipleLimits.Equals(false))
{
tbl1.Cell(1, 2).Range.Text = sCurType + iIndemnLimit;
}
else
{
tbl1.Cell(1, 2).Range.Text = stripIndemLimitCode(iIndemnLimit).ToString();
}
等等,等等……
我的问题是,即使没有要解析的数据,表格是否应该显示……说我是否想逐行测试解析数据?或者填充表格的代码是否需要存在并正确才能显示表格???
我希望我没有啰嗦太多,把我的问题弄糊涂了……
谢谢大家!!!