Tabulka

Příklady přidávání tabulek, přístupu k nim, odstraňování a slučování buněk pomocí Aspose.Slides for .NET.

Přidat tabulku

Vytvořte jednoduchou tabulku se dvěma řádky a dvěma sloupci.

static void AddTable()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    double[] widths = { 80, 80 };
    double[] heights = { 30, 30 };
    var table = slide.Shapes.AddTable(50, 50, widths, heights);
}

Přístup k tabulce

Získejte první tvar tabulky na snímku.

static void AccessTable()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    double[] widths = { 80, 80 };
    double[] heights = { 30, 30 };
    var table = slide.Shapes.AddTable(50, 50, widths, heights);

    // Přístup k první tabulce na snímku.
    var firstTable = slide.Shapes.OfType<ITable>().First();
}

Odstranit tabulku

Odstraňte tabulku ze snímku.

static void RemoveTable()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    double[] widths = { 80, 80 };
    double[] heights = { 30, 30 };
    var table = slide.Shapes.AddTable(50, 50, widths, heights);

    slide.Shapes.Remove(table);
}

Sloučit buňky tabulky

Sloučte sousední buňky tabulky do jedné buňky.

static void MergeTableCells()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];
    
    double[] widths = { 80, 80 };
    double[] heights = { 30, 30 };
    var table = slide.Shapes.AddTable(50, 50, widths, heights);

    table.MergeCells(table[0, 0], table[1, 1], false);
}