Tableau
Contents
[
Hide
]
Exemples d’ajout de tableaux, d’accès à ceux-ci, de suppression et de fusion des cellules à l’aide de Aspose.Slides for C++.
Ajouter un tableau
Créez un tableau simple avec deux lignes et deux colonnes.
static void AddTable()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto widths = MakeArray<double>({ 80, 80 });
auto heights = MakeArray<double>({ 30, 30 });
auto table = slide->get_Shapes()->AddTable(50, 50, widths, heights);
presentation->Dispose();
}
Accéder à un tableau
Récupérez la première forme de tableau sur la diapositive.
static void AccessTable()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto widths = MakeArray<double>({ 80, 80 });
auto heights = MakeArray<double>({ 30, 30 });
auto table = slide->get_Shapes()->AddTable(50, 50, widths, heights);
// Accéder au premier tableau sur la diapositive.
auto firstTable = SharedPtr<ITable>();
for (auto&& shape : slide->get_Shapes())
{
if (ObjectExt::Is<ITable>(shape))
{
firstTable = ExplicitCast<ITable>(shape);
break;
}
}
presentation->Dispose();
}
Supprimer un tableau
Supprimez un tableau d’une diapositive.
static void RemoveTable()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto widths = MakeArray<double>({ 80, 80 });
auto heights = MakeArray<double>({ 30, 30 });
auto table = slide->get_Shapes()->AddTable(50, 50, widths, heights);
slide->get_Shapes()->Remove(table);
presentation->Dispose();
}
Fusionner les cellules du tableau
Fusionnez les cellules adjacentes d’un tableau en une seule cellule.
static void MergeTableCells()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto widths = MakeArray<double>({ 80, 80 });
auto heights = MakeArray<double>({ 30, 30 });
auto table = slide->get_Shapes()->AddTable(50, 50, widths, heights);
// Fusionner les cellules.
table->MergeCells(table->idx_get(0, 0), table->idx_get(1, 1), false);
presentation->Dispose();
}