如何一次格式化所有 Migradoc 表的单元格?

罗米亚斯

我正在使用 Migradoc 创建一个表格,我想设置所有单元格的底纹颜色和单元格边框。

在这一点上,我只能逐个单元地执行此操作:

        var tableRow = table.AddRow();            
        table.Cells[0].Shading.Color = Colors.LightBlue;
        table.Cells[0].Format.LeftIndent = 1;
        table.Cells[0].Borders.Color = Colors.White;
        table.Cells[0].Borders.Width = 4;

        table.Cells[1].Shading.Color = Colors.LightBlue;
        table.Cells[1].Format.LeftIndent = 1;
        table.Cells[1].Borders.Color = Colors.White;
        table.Cells[1].Borders.Width = 4;

如果它在一个循环内,它不会那么痛苦,但我所有的行都是一一创建的。

如何将这些属性设置为表中的所有单元格?

哈桑·蒙杰兹

你可以混合RowsColumnsStyle实现你想要的:

        // Create a new style called Table based on style Normal
        Style style = document.Styles.AddStyle("Table", "Normal"); //this is optional, you can have your own style :) 
        style.Font.Name = "Verdana";
        style.Font.Name = "Times New Roman";
        style.Font.Size = 9;

        Table table = new Table();
        table.Style = "Table";
        table.Rows.LeftIndent = -1; //to indent all the rows
        table.Columns.Width = 4; //width of all the columns
        table.Borders.Color = Colors.White; //color of all the border 
        table.Shading.Color = Colors.LightBlue; //all the cells table shading color

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章