Skip to main content
All docs
V25.2
  • TableCell Class

    A cell in a slide’s table.

    Namespace: DevExpress.Docs.Presentation

    Assembly: DevExpress.Docs.Presentation.v25.2.dll

    Declaration

    public class TableCell :
        PresentationObject,
        ITextRunEnumerable

    The following members return TableCell objects:

    Remarks

    For more information about tables, refer to the following help topic: DevExpress Presentation API Library: Work with Tables.

    Example: Create and Add a Table to a Slide

    Follow the steps below to create a table and add it to a slide:

    • Create a Table object and specify the number of rows and columns in the Table constructor.
    • Use the table’s X, Y, Width, and Height properties to set the table’s position and size on the slide. All these properties are measured in Document units (1/300 of an inch). You can also set these properties in a Table constructor.
    • Add the table to the slide’s Shapes collection.
    • Use the table’s indexer to access individual cells.
    • Use the cell’s TextArea property to add text to the cell. Note that cells support only text content.

    The following code snippet creates a 3x3 table, adds it to a slide, and populates the cells with text:

    DevExpress Presentation API - Create and Add a Table to a Slide

    using DevExpress.Docs.Presentation;
    
    namespace PresentationApiSample;
    
    public class Program {
        public static void Main(string[] _) {
    
            // Create an in-memory Presentation document
            Presentation presentation = new Presentation();
            presentation.Slides.Clear();
    
            // Create a blank slide and add it to the presentation
            Slide slide = new Slide(SlideLayoutType.Blank);
            presentation.Slides.Add(slide);
    
            // Create a 3x3 table (rows x columns), specify its position and size, and add the table as a shape to the slide
            Table table = new Table(3, 3);
            table.X = 10;
            table.Y = 10;
            table.Width = 2500;
            table.Height = 2000;
            slide.Shapes.Add(table);
    
            // Populate table cell text (row, column)
            for (int row = 0; row < 3; row++) {
                for (int column = 0; column < 3; column++) {
                    table[row, column].TextArea.Text = $"({row}, {column})";
                }
            }
    
            // Export the presentation to PDF
            presentation.ExportToPdf(new FileStream(@"D:\\exported-document.pdf", FileMode.Create));
    
            // Save the presentation as a PPTX file
            FileStream outputStream = new FileStream(@"D:\\presentation.pptx", FileMode.Create);
            presentation.SaveDocument(outputStream, DocumentFormat.Pptx);
            outputStream.Dispose();
        }
    }
    

    Implements

    Inheritance

    See Also