Free Support Forum - aspose.com

Problem in setting the table height

Hi

I have set the height for the Table using "SetRowHeight" but when i try to retrieve the height, i am gettnig "328" as the value for those values i have set between 100 and 200. Please confirm me whether it is the limitaion of AsposeSlides or do i have to set any other property.

Thanks,

Regilesh

Dear Regilesh,


Thanks for using Aspose.Slides.

Row height depends on the font height, for example, if font height is greater than the row height, then row height will be adjusted accordingly.

The code below has set the font height to 4 and then setting the row height to 100 works quite fine.

To change table height, you should use Table.Height property.

Presentation srcPres = new Presentation();

Slide srcSld = srcPres.GetSlideByPosition(1);

Table tbl=srcSld.Shapes.AddTable(300, 500, 5000, 1, 1, 1);

//set the row height to 100

tbl.SetRowHeight(0, 100);

//change the font height to 4

Aspose.Slides.Cell cl = tbl.GetCell(0, 0);

cl.TextFrame.Paragraphs[0].Portions[0].FontHeight = 4;

//retrieve row height, it is same as we set earlier

int rh = tbl.GetRowHeight(0);

Hi,

The follwing process i have done for setting the height of the table row.Please see the attachment for more details with code.

1: Assigned the height for the 0th row of PPT tabel.

2: Set the height as 173.599991 for 0th row.

3: After set the height ,retrieved the height of the 0th row by using of getRowHeight(0) function.but it returns as "328"

Its always retruning "328".Please confirm me any other way to set the height and please advice me whether i missed any steps.

please see the follwing code .we created this function to assign the height of gridrow into ppttable row height.

private void SetRowSize

(

Table pptTable,

GridRow gridRow

)

{

float height = 0;

switch (gridRow.SizingStyle)

{

//only manual size is currently in use

case SizingStyle.Manual :

height = gridRow.Height;

break;

case SizingStyle.Auto :

height = GetRowAutoSize(gridRow);

break;

case SizingStyle.Default :

default :

height = GetRowDefaultSize(gridRow);

break;

}

pptTable.SetRowHeight(gridRow.Row, Convert.ToInt32(height));

}

Thanks,

Regilesh

As I said, if font height (in pixels) is larger than row height, then row height will be ignored.

So please decrease the font size in all the cells of your first row first.

You can also experiment it in MS-PowerPoint, create a table with some rows and columns and then try to decrease the height of any row, after certain limit, you could not decrease it unless you decrease the font size in the cells of that particular row.

I have attached the execution image of my previous code. As you can see, Table.GetRowHeight returns correct height.