簡體   English   中英

由C#創建的Word文檔中的表格和單元格 - 如何僅更改一個邊框的顏色?

[英]Tables and cells in Word document created by C# - how to change color of only one border?

我有帶有表格的MS Word文檔,全部由C#創建。 我遇到的問題是如何僅在兩個單元格之間更改邊框顏色,而不是更改整個表格? 有可能嗎?

Word文檔是在“正常”的方式創建,如所描述這里

你能幫幫我嗎?

更新:使用下一篇文章創建Word文檔和表: http//support.microsoft.com/kb/316384

不確定我選擇了合適的表格,但這里有一個想法:

    oTable.Cell(0, 0).Select(); //select the cell
//set up the left, right and top borders invisible (may be you don't need to do that)
            oTable.Range.Borders[WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone;
            oTable.Range.Borders[WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone;
            oTable.Range.Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone;

//set up the bottom border blue
            oTable.Range.Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle;
            oTable.Range.Borders[WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt;
            oTable.Range.Borders[WdBorderType.wdBorderBottom].Color = WdColor.wdColorBlue;

通常,如果我想做某事我不知道如何做到這一點只需打開辦公室程序(在你的情況下為Word),啟動宏,做一些事情,記錄,然后看到生成的代碼。 通常,了解如何實現它就足夠了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM