【发布时间】:2015-03-28 13:40:03
【问题描述】:
使用 powershell 可以像这样在表格单元格中添加文本,现在我想格式化单元格文本。
table.Cell(1, 1).Range.Text = "ListvItem1vitem2"
例如。 我想加粗并对齐中心“列表”字符串。为 Item1 和 Iteam2 字符串应用有序项目样式。 如何使用 powershell 做到这一点?
编辑: 在 C# 中找到此代码,无法使其在 powershell 中运行。
//boldrange_1 for "green", boldrange_2 for "inch".
Word.Range boldrange_1 = table.Cell(1, 2).Range;//Assign the whole cell range to boldrange, then adjust it with SetRange method.
boldrange_1.SetRange(table.Cell(1, 2).Range.Start, table.Cell(1, 2).Range.Words[1].End);
boldrange_1.Bold= 1;
Word.Range boldrange_2 = table.Cell(2, 2).Range;
boldrange_2.SetRange(table.Cell(2, 2).Range.Words[4].End, table.Cell(2, 2).Range.Words[5].End);
boldrange_2.Font.Bold = 1;
//I've found that boldrange_2.Font.Bold = 1; and boldrange_2.Bold = 1; have the same effect.
【问题讨论】:
标签: powershell ms-word