Rockyboys 2019-01-04 13:47 采纳率: 0%
浏览 1510

aspose word 表格单元格行距问题。

Table outerTable = CreateTable(doc, 3, 6, "");
///
///创建几行几列表格 Creates a new table in the document with the given dimensions and text in each cell.
///
private Table CreateTable(Document doc, int rowCount, int cellCount, string cellText)
{
Table table = new Table(doc);
// Create the specified number of rows.
for (int rowId = 1; rowId <= rowCount; rowId++)
{
Row row = new Row(doc);
table.AppendChild(row);

            // Create the specified number of cells for each row.
            for (int cellId = 1; cellId <= cellCount; cellId++)
            {
                Cell cell = new Cell(doc);  
                //需要设置一下这个值
                Paragraph p = new Paragraph(doc);
                p.AppendChild(new Run(doc, "")); 
                p.ParagraphFormat.Style.Font.Size = 10;
                p.ParagraphFormat.Style.Font.Name = "Arial"; 
                p.ParagraphFormat.Alignment = ParagraphAlignment.Center;
               p.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple; // 设置段落 
                p.ParagraphFormat.LineSpacing = 12;                            // 设置段落 默认给的是15.6磅**
                cell.AppendChild(p);   
                //  cell.CellFormat.Shading.BackgroundPatternColor = 颜色 ;
                cell.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;

// cell.FirstParagraph.AppendChild(new Run(doc, cellText));
row.AppendChild(cell);
}
}
return table;
}

p.ParagraphFormat.Alignment = ParagraphAlignment.Center;
p.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple; // 设置段落
p.ParagraphFormat.LineSpacing = 12; // 设置段落 默认给的是15.6磅
cell.AppendChild(p);

cell.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
cell.FirstParagraph.AppendChild(new Run(doc,“test”));
row.AppendChild(cell);

p.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple; // 设置段落
p.ParagraphFormat.LineSpacing = 12; // 设置段落 默认给的是15.6磅
为何段落设置不起作用

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样