Back to Devexpress

TableCell.TextArea Property

officefileapi-devexpress-dot-docs-dot-presentation-dot-tablecell.md

latest5.4 KB
Original Source

TableCell.TextArea Property

Gets or sets the table cell text box that allows you specify cell content and its formatting.

Namespace : DevExpress.Docs.Presentation

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

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public CellTextArea TextArea { get; set; }
vb
Public Property TextArea As CellTextArea

Property Value

TypeDescription
CellTextArea

A table cell text box.

|

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:

csharp
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();
    }
}
vb
Imports DevExpress.Docs.Presentation

Namespace PresentationApiSample

    Public Class Program
        Public Shared Sub Main(__ As String())
            ' Create an in-memory Presentation document
            Dim presentation As Presentation = New Presentation()
            presentation.Slides.Clear()

            ' Create a blank slide and add it to the presentation
            Dim slide As 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
            Dim table As 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 row As Integer = 0 To 2
                For column As Integer = 0 To 2
                    table(row, column).TextArea.Text = $"({row}, {column})"
                Next
            Next
            ' Export the presentation to PDF
            presentation.ExportToPdf(New FileStream("D:\\exported-document.pdf", FileMode.Create))

            ' Save the presentation as a PPTX file
            Dim outputStream As FileStream = New FileStream("D:\\presentation.pptx", FileMode.Create)
            presentation.SaveDocument(outputStream, DocumentFormat.Pptx)
            outputStream.Dispose()
        End Sub
    End Class
End Namespace

See Also

TableCell Class

TableCell Members

DevExpress.Docs.Presentation Namespace