如何在MS Word表格单元格中将文本的一部分加粗?

时间:2021-10-12 05:37:27

I have a C# application which uses an MS Word document. I have tables where some of the text in a cell needs to be bold. Is there a way to do it?

我有一个使用MS Word文档的C#应用​​程序。我有表格,其中一个单元格中的一些文本需要加粗。有办法吗?

1 个解决方案

#1


I assume you are using Microsoft Office Interop.

我假设您使用的是Microsoft Office Interop。

The example which I found on: http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=48632 says:

我在上面找到的例子:http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=48632说:

using Microsoft.Office.Interop.Word;

using Microsoft.Office.Core;

Document varDoc = varWord.Documents.Add(ref varMissing, ref varMissing, ref varMissing, ref varTrueValue);

varDoc.Activate();

varDoc.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader;

varDoc.ActiveWindow.Selection.Font.Bold = 1;

Similarly use it in your App.

同样在你的App中使用它。

Else if you are using HTML Tables, then a dirty way is to use

否则,如果您使用HTML表格,则使用脏方法

html tags.

#1


I assume you are using Microsoft Office Interop.

我假设您使用的是Microsoft Office Interop。

The example which I found on: http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=48632 says:

我在上面找到的例子:http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=48632说:

using Microsoft.Office.Interop.Word;

using Microsoft.Office.Core;

Document varDoc = varWord.Documents.Add(ref varMissing, ref varMissing, ref varMissing, ref varTrueValue);

varDoc.Activate();

varDoc.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader;

varDoc.ActiveWindow.Selection.Font.Bold = 1;

Similarly use it in your App.

同样在你的App中使用它。

Else if you are using HTML Tables, then a dirty way is to use

否则,如果您使用HTML表格,则使用脏方法

html tags.