Free Support Forum -

How to get a Table cell content?


is there a way to get a table cell content once created?

I have a function that builds a PDF Table passing it to another function which should read the cells content.

The Cell class has Paragraphs collection of Paragraph and the Paragraph class has not a method to get its content.

Using your sample:

Pdf pdf1 = new Pdf();

Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
table1.ColumnWidths = "70 2cm";

Row row1 = table1.Rows.Add();

Cell cell1Row1 = row1.Cells.Add("ColumnsSpan = 2");
cell1Row1.ColumnsSpan = 2;
cell1Row1.Border = new BorderInfo((int)BorderSide.All,0.5F);

Row row2 = table1.Rows.Add();

Cell cell1Row2 = row2.Cells.Add("cell1");
cell1Row2.Border = new BorderInfo((int)BorderSide.All,0.5F);

Cell cell2Row2 = row2.Cells.Add("cell2");
cell2Row2.Border = new BorderInfo((int)BorderSide.All,0.5F,new Aspose.Pdf.Color("Red"));


How the get "cell1" or "cell2" back from cell1Row2 or cell2Row2 ?



Dear vmax,

Thank you for considering Aspose.

You can get the content of the cell like the following:

Paragraph para1 = cell1.Paragraphs[0];
if(para1 is Text)
Text t1 = para1 as Text;