Table Height and cell Height

I have set the tableHeight when constructing a new table and call table.SetRowHeight for each row. But it does not work at all. No matter what value I set to the height, it just act the same. What’s wrong? Thanks!

Hi Daizy,

Thanks for considering Aspose.Slides.

I have tried to reproduce the issue specified by you and I have been successfully able to adjust the height of row. Can you please share the code snippet and source presentation with us? So that we can further investigate the issue.

Thanks and Regards,

First, I wrote like this:

int xPosition = 10;
int yPosition = 471;
int tableWidth = 500;
int tableHeight = 500;
int columns = 10;
int rows = 10;
Table table = slide.Shapes.AddTable(xPosition, yPosition, tableWidth, tableHeight, columns, rows);

the cell should look like a square with the length of 50, but it didn't turn out like that.

then I added the following snippet to change the length:

for (int i = 0; i != columns; ++i)
{
table.SetColumnWidth(i, 10);
}
for (int i = 0; i != rows; ++i)
{
table.SetRowHeight(i, 10);
}

nothing changed.

Then for the following code:

for (int i = 0; i != columns; ++i)
{
table.SetColumnWidth(i, 100);
}
for (int i = 0; i != rows; ++i)
{
table.SetRowHeight(i, 100);
}

nothing changed, either.

it turns out that setting the column width works while setting the row height doesn’t work at all.

Hi Daizy,

Below please find the code snippet that I have used for getting and setting row height. Inside For-Loop, I am getting the old row height and setting the new one. I have used Aspose.Slides for .NET 4.1.1 for the following code. Hopefully, things may work for you this time.

int xPosition = 880;
int yPosition = 1400;
int tableWidth = 6000;
int tableHeight = 500;
int columns = 5;
int rows = 10;

try
{
    //Accessing the text frame of the first cell of the first row in the table
    Presentation pres = new Presentation();
    Slide slide;
    Aspose.Slides.Table table;

    slide = pres.AddEmptySlide();
    table = slide.Shapes.AddTable(xPosition, yPosition, tableWidth, tableHeight,
        columns, rows, borderWidth, Color.Blue);

    table.AlternativeText = "myTable " + slid_count;

    int iTempHeight = 0;
    for (int row = 0; row < rows; row++)
    {
        //Please verify the Row height feature here
        iTempHeight = table.GetRowHeight(row);
        table.SetRowHeight(row, iTemoHeight + 100);
        iTemoHeight = table.GetRowHeight(row);

        for (int col = 0; col < columns; col++)
        {
            TextFrame tf = table.GetCell(col, row).TextFrame;
            if (tf != null)
            {
                tf.Paragraphs[0].Portions[0].Text = "This is row: “+row+” col: " + col;
            }
        }
    }

    //Writing the presentation as a PPT file
    pres.Write("D:\\modified.ppt");
}
catch (Exception e)
{
    Console.WriteLine(e.StackTrace);
}

Thanks and Regards,