gpt4 book ai didi

c#-4.0 - 如何在MigraDoc表中设置单元格的背景色

转载 作者:行者123 更新时间:2023-12-03 23:26:13 24 4
gpt4 key购买 nike

我有一个MigraDoc表,其中指定的行高为0.75cm,并且文本在单元格的中间垂直对齐。当我将cell.Format.Shading.Color设置为非白色时,边框附近仍然有一部分单元格在所有四个侧面都显示为白色。

我发现可以通过设置column.LeftPadding = 0和column.RightPadding = 0来删除文本左右两侧的白色部分。但是,我无法弄清楚如何在文本的顶部/底部获得白色条纹消失而不会影响文本的垂直对齐方式。如果将段落线的高度更改为0.75厘米,则条纹消失,但是文本随后在单元格内底部对齐。我无法设置列底纹颜色,因为列中的每个单元格包含不同的颜色。有谁知道一种强制段落垂直填充单元格的方法(或者以其他方式使背景颜色在单元格内均匀)?

这是我的代码示例(在C#中),其中表的类型为MigraDoc.DocumentObjectModel.Tables.Table:

...

// Add a column at index #2
var column = table.AddColumn();
column.LeftPadding = 0;
column.RightPadding = 0;

// Add more columns
...

// Iterate through the data printed in each row
foreach (var rowData in myData)
{
// Create a row for the data
var row = table.AddRow();
row.Height = ".75cm";
row.Format.Font.Size = 11;
row.VerticalAlignment = VerticalAlignment.Center;

...

// The following is for illustrative purposes... the actual
// colors and text is determined by the data within the cell
var cell = row.Cells[2];
cell.Format.Shading.Color = Colors.Black;
cell.Format.Font.Color = Colors.White;
var paragraph = cell.AddParagraph("Example");

...
}

最佳答案

尝试使用cell.Shading.Color代替cell.Format.Shading.Color-前者设置单元格的颜色,后者设置文本背景的颜色(然后单元格的填充将具有不同的颜色)。

关于c#-4.0 - 如何在MigraDoc表中设置单元格的背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29438907/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com