0
我有一個充滿書籤的單詞模板,但是當我嘗試插入一個表時,我陷入了困境......首先,我發出了一個COMException,表示請求的集合成員不存在。意味着設置的書籤與我現在調用的表名稱不同。無論如何,表格根本不顯示..我已經在數據輸入到表格之前設置了格式...
像這樣:Word 2010表
// 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();
}
等等...
我的問題確實是,即使沒有數據需要解析也應該顯示錶...如果我想按行測試解析數據行嗎?或者填充表格的代碼需要存在並且正確地爲表格顯示?
我希望我havnt狼吞虎嚥太多,困惑我的問題..
謝謝你們!