Table and cell heights

Table addtable = slide.getshapes().addtable( 0, 0, 4000, 500, 2, 2, 1, color.black )

The height of the table is being set to 656 instead of 500, and the only way to change the height of the table is to make it 656 or above.

Is 656 the lowest a table height can be?

Also when I add text to the text frame within each cell, the cell height increases instead of uitilising all the height assigned to the cell before increasing.

I have just checked and it seems that i cannot get cells to be any lower than 328 if I increase my number of rows the height of the table increases by this much. Also when I click the cursor in the drawn table it expects some text with a font size of 28.

Dear Harry,

Aspose.Slides does not restrict the table height; it is actually because of font height inside the cells.

You can observe such a behavior by creating a table in MS-PowerPoint and try to decrease the table height, it will not decrease further unless you decrease the font height inside cells.

How do you set the cell font, I thought that the text you added detemined the font size in a cell, in my case this is 12, but instead I get my text printed in size twelve correctly and then a huge empty space that expects font size 28.

Harry

It is because, there will be two portions, one portion had a height 12 and other had a font heigh 28.

Below is the way to set font height of the cell.

//setting the font height of first portion of the first paragraph

tbl.getCell(col,row).getTextFrame().getParagraphs().get(0).getPortions().get(0).setFontHeight(newFontHeight);

Here is the code to set the font height of first row in the table

short newFontHeight=12;

int colsCount=tbl.getColumnsNumber();

int targetRow=0; //suppose it is first row.

for(int col=0; col<colsCount; col++)

{

Cell cl=tbl.getCell(col,targetRow);

int parasCount=cl.getTextFrame.getParagraphs().size();

for(int para=0; para<parasCount; para++)

{

Paragraph para=cl.getTextFrame.getParagraphs().get(para);

int portsCount=para.getPortions().size();

//now set the height of every portion

for(int port=0; port<portsCount; port++)

{

Portion portion=para.getPortions().get(port);

portion.setFontHeight(newFontHeight);

}//end for

}//end for

}//end for