第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用單詞插件在當(dāng)前位置添加表格

使用單詞插件在當(dāng)前位置添加表格

C#
撒科打諢 2022-07-23 09:01:54
我想用我的 Word 加載項(xiàng)添加一個(gè)表,其中包含我數(shù)據(jù)庫(kù)中的數(shù)據(jù)。我已經(jīng)成功地做到了,但現(xiàn)在我對(duì)桌子的位置有疑問(wèn)。我想把它準(zhǔn)確地放在我在 Word 文檔中的當(dāng)前位置。但是,它總是在開(kāi)頭添加。有誰(shuí)知道如何調(diào)整我的起始值始終是我當(dāng)前位置的范圍?這是我的代碼的一部分:private void createTable_Click(object sender, EventArgs e) {object start = 0, end = 0;Word.Document document = Globals.ThisAddIn.Application.ActiveDocument; Word.Range rng = document.Range(ref start, ref end);// Insert a title for the table and paragraph marks.rng.InsertBefore("List"); rng.Font.Name = "Verdana"; rng.Font.Size = 16; rng.InsertParagraphAfter(); rng.InsertParagraphAfter(); rng.SetRange(rng.End, rng.End);// Add the table.rng.Tables.Add(document.Paragraphs[2].Range, 1, 7, ref missing, ref missing);// Format the table and apply a style.Word.Table tbl = document.Tables[1]; tbl.Range.Font.Size = 8;   tbl.Borders[WdBorderType.wdBorderLeft].LineStyle =  WdLineStyle.wdLineStyleSingle; tbl.Borders[WdBorderType.wdBorderRight].LineStyle =  WdLineStyle.wdLineStyleSingle; tbl.Borders[WdBorderType.wdBorderTop].LineStyle =  WdLineStyle.wdLineStyleSingle; tbl.Borders[WdBorderType.wdBorderBottom].LineStyle =  WdLineStyle.wdLineStyleSingle; tbl.Borders[WdBorderType.wdBorderHorizontal].LineStyle =  WdLineStyle.wdLineStyleSingle; tbl.Borders[WdBorderType.wdBorderVertical].LineStyle =  WdLineStyle.wdLineStyleSingle;tbl.Borders[WdBorderType.wdBorderBottom].Color = WdColor.wdColorBlack; tbl.Rows.Alignment = WdRowAlignment.wdAlignRowCenter; tbl.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitWindow);
查看完整描述

1 回答

?
ITMISS

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊

重新閱讀...在當(dāng)前位置插入 - 如果您的意思是光標(biāo)所在的位置:


Word.Range rngSel = wdApp.Selection.Range;

rngSel.Tables.Add(//params here);

否則,如果您的意思是在代碼插入信息的末尾,而不是這兩行


rng.InsertBefore("List"); 

rng.Font.Name = "Verdana"; 

rng.Font.Size = 16; 

rng.InsertParagraphAfter(); 

rng.InsertParagraphAfter(); 

rng.SetRange(rng.End, rng.End);

利用


rng.Text = "List\n\n"

rng.Font.Name = "Verdana"; 

rng.Font.Size = 16; 

rng.Collapse(WdCollapseDirection.wdCollapseEnd);

\n插入一個(gè)新段落(回車(chē))并且可以作為字符串的一部分。


將文本直接分配給該方法Range并使用該Collapse方法(在我看來(lái))比各種 Insert 方法更容易預(yù)測(cè)。一些 Insert 方法包括在范圍內(nèi)插入的內(nèi)容,而另一些則不包括。


FWIW 當(dāng)不清楚問(wèn)題可能是什么時(shí),它可以幫助將 arng.Select();放在代碼中的關(guān)鍵點(diǎn)并注釋掉其余的行,以便代碼以可見(jiàn)的范圍結(jié)束。這通??梢蕴峁┯嘘P(guān)范圍問(wèn)題根源的信息。


查看完整回答
反對(duì) 回復(fù) 2022-07-23
  • 1 回答
  • 0 關(guān)注
  • 104 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)