单词表隐藏上一个文本行

时间:2014-07-25 11:48:37

标签: c#

我的项目是第一行的窗口形式我写了一个文本到ms字,然后我试图在该文本后绘制表格(在下一行,我的意思是第2行),表格可见,但隐藏了以前的文字。我需要表格在下一行。我可以解决这个错误 我还需要在该表之后写另一个文本

start = Type.Missing;
end = Type.Missing;
rng_x = oDataDoc.Range(ref start, ref end);
rng_x.Text = "name ,grade and age etc...  ";
rng_x.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;

start = oDataDoc.Characters.Count;
end = Type.Missing;
rng_x = oDataDoc.Range(ref start, ref end);
Nrow=4; Ncolumn=8;
oDataDoc.Tables.Add(rng_x, Nrow, Ncolumn, ref defaultTableBehavior, ref      AutoFitBehavior);
 Word.Table tbl = oDataDoc.Tables[1];

1 个答案:

答案 0 :(得分:0)

找到了答案

start = Type.Missing;
end = Type.Missing;
rng_x = oDataDoc.Range(ref start, ref end);
rng_x.Text = "hellow";
rng_x.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
float wordY = (float)rng_x.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage);
istart = (int)wordY;
iend = (int)wordY;
rng_x.SetRange(istart,iend);
Nrow=4; Ncolumn=8;
oDataDoc.Tables.Add(rng_x, Nrow, Ncolumn, ref defaultTableBehavior, ref autoFitBehavior);
Word.Table tbl = oDataDoc.Tables[1];