在用 aspose slide 制作的表格中合并行

问题描述 投票:0回答:0

我做了我的小表格,这个表格根据我在每一栏放的内容不同,也就是说,如果我在一栏告诉它我想要它去,例如Signature和Name,它会画那些同一列中的两个值,在第二列中我说位置,类型,即,按以下方式将是:

enter image description here

从 Content.Split(',').Length 我得到我要在我的桌子上画的内容

for (int i = 0; i < Contenido.Count; i++)
                                                    {
                                                        int x = 0;
                                                        x = Contenido.Split(',').Length;

                                                        
                                                            if (x != 1)
                                                            {
                                                                //Rows = fila + Content.Length;
                                                                tbl.MergeCells(tbl[0,1], tbl[0,2], false);

                                                                //tbl.MergeCells(tbl[columna, fila], tbl[columna, fila], false);

                                                            }
                                                        

                                                    }

就像上面我带了一个 for() ,我仍然拿出我的内容长度来把它画在桌子上,它在第一轮中做了什么它去寻找它通过开关的签名它找到签名并绘制它,从那里在第二个后面它去寻找它绘制它的名字,这就是合并效果不佳的原因,因为我告诉它为我绘制那些行但是因为它们还没全部遍历

                                                for (var fc = 0; fc < Content.Length; fc++)
                                                {
                                                   
                                                    fila++;
                                                   
                                                    switch (Content[fc])
                                                    {
                                                        case "Nombre":
                                                            tbl[columna, fila].TextFrame.Text = Nombre;
                                                           
                                                            break;
}
}

我希望它是这样的

enter image description here

我的代码类似下面

// Instantiates the Presentation class that represents a PPTX file
using (Presentation presentation = new Presentation())
{
    // Accesses the first slide
    ISlide slide = presentation.Slides[0];

    // Defines columns with widths and rows with heights
    double[] dblCols = { 70, 70, 70, 70 };
    double[] dblRows = { 70, 70, 70, 70 };

    // Adds a table shape to the slide
    ITable table = slide.Shapes.AddTable(100, 50, dblCols, dblRows);

    // Sets the border format for each cell
    foreach (IRow row in table.Rows)
    {
        foreach (ICell cell in row)
        {
            cell.CellFormat.BorderTop.FillFormat.FillType = FillType.Solid;
            cell.CellFormat.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
            cell.CellFormat.BorderTop.Width = 5;

            cell.CellFormat.BorderBottom.FillFormat.FillType = FillType.Solid;
            cell.CellFormat.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
            cell.CellFormat.BorderBottom.Width = 5;

            cell.CellFormat.BorderLeft.FillFormat.FillType = FillType.Solid;
            cell.CellFormat.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
            cell.CellFormat.BorderLeft.Width = 5;

            cell.CellFormat.BorderRight.FillFormat.FillType = FillType.Solid;
            cell.CellFormat.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
            cell.CellFormat.BorderRight.Width = 5;

        }
    }

    // Merges cells (1, 1) x (2, 1)
    table.MergeCells(table[1, 1], table[2, 1], false);

    // Merges cells (1, 2) x (2, 2)
    table.MergeCells(table[1, 2], table[2, 2], false);

    // Merges cells (1, 2) x (2, 2)
    table.MergeCells(table[1, 1], table[1, 2], true);

    //Writes the PPTX file to disk
    presentation.Save("MergeCells1_out.pptx", SaveFormat.Pptx);
}
c# .net row aspose-slides
© www.soinside.com 2019 - 2024. All rights reserved.