AddTable
ShapeCollection.AddTable method
Crea una nueva tabla y la añade al final de la colección.
public ITable AddTable(float x, float y, double[] columnWidths, double[] rowHeights)
Parámetro | Tipo | Descripción |
---|---|---|
x | Single | La coordenada X para un lado izquierdo del marco de la forma. |
y | Single | La coordenada Y para un lado superior del marco de la forma. |
columnWidths | Double[] | Array de dobles que representa los anchos de las columnas en la tabla. |
rowHeights | Double[] | Array de dobles que representa las alturas de las filas en la tabla. |
Valor de Retorno
Objeto de tabla creado.
Ejemplos
Los siguientes ejemplos muestran cómo añadir una tabla en una presentación de PowerPoint.
[C#]
// Instanciar la clase Presentation que representa el archivo PPTX
using (Presentation pres = new Presentation()){
// Acceder a la primera diapositiva
ISlide sld = pres.Slides[0];
// Definir columnas con anchos y filas con alturas
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };
// Añadir forma de tabla a la diapositiva
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
// Establecer formato de borde para cada celda
for (int row = 0; row < tbl.Rows.Count; row++)
{
for (int cell = 0; cell < tbl.Rows[row].Count; cell++)
{
tbl.Rows[row][cell].CellFormat.BorderTop.FillFormat.FillType = FillType.Solid;
tbl.Rows[row][cell].CellFormat.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
tbl.Rows[row][cell].CellFormat.BorderTop.Width = 5;
tbl.Rows[row][cell].CellFormat.BorderBottom.FillFormat.FillType = (FillType.Solid);
tbl.Rows[row][cell].CellFormat.BorderBottom.FillFormat.SolidFillColor.Color= Color.Red;
tbl.Rows[row][cell].CellFormat.BorderBottom.Width =5;
tbl.Rows[row][cell].CellFormat.BorderLeft.FillFormat.FillType = FillType.Solid;
tbl.Rows[row][cell].CellFormat.BorderLeft.FillFormat.SolidFillColor.Color =Color.Red;
tbl.Rows[row][cell].CellFormat.BorderLeft.Width = 5;
tbl.Rows[row][cell].CellFormat.BorderRight.FillFormat.FillType = FillType.Solid;
tbl.Rows[row][cell].CellFormat.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
tbl.Rows[row][cell].CellFormat.BorderRight.Width = 5;
}
}
// Combinar celdas 1 y 2 de la fila 1
tbl.MergeCells(tbl.Rows[0][0], tbl.Rows[1][1], false);
// Añadir texto a la celda combinada
tbl.Rows[0][0].TextFrame.Text = "Celdas Combinadas";
// Guardar PPTX en el disco
pres.Save("table.pptx", SaveFormat.Pptx);
}
Ver También
- interface ITable
- class ShapeCollection
- namespace Aspose.Slides
- assembly Aspose.Slides