python-pptx table - keep row height as small as possible -


i want create table short can possibly be, i.e. have smallest row height possible, while fitting prescribed text @ prescribed size. using code:

i initialize table:

init_table_width = prs.slide_width - inches(0.2) graphicframe = slide.shapes.add_table(rows = len(biosets) + 1, cols=5, left=inches(0.1), top=inches(.76), width=init_table_width, height=prs.slide_height - inches(.76 + 3.2)) table = graphicframe.table 

i populate table , set cell properties this:

for in range(len(biosets)):     new_row = ['bioset'+str(i+1)+': '+biosets[i], studies[i], correlation[i], common_genes[i], pvals[i]]     rownum += 1     col_index, col_name in enumerate(new_row):         cell = table.cell(rownum, col_index)         cell.text = col_name         cell.margin_left = cell.margin_right = cell.margin_top = cell.margin_bottom = 0;         cell.text_frame.paragraphs[0].font.size = pt(7.5) 

when open ppt presentation, table taller i’d like. can drag bottom of table , reduce height of table automatically created. why there height can reduced, if set margins 0? table created has height greater height initialized table; when manually drag & reduce table height, height less height initialized table. means have fit contents table of size desired. text did wrap in few rows, may explain why expanded original size. so, why there height can drag , reduce if set cell margins 0? element contributing , how can rid of it? don’t want hard code row.height, because don’t know when text wrap on 2 lines.

i figured out if initialize table impossibly small height (see height=1 below), table gets created have compact row height possible.

graphicframe = slide.shapes.add_table(len(biosets) + 1, cols=5, left=inches(0.1), top=inches(.76), width=init_table_width, height=1) 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -