python pptx table_Python PPTX table.cell颜色

defcreate_default_slide(user,ppt,shapes,experience_text,skills):max_height=Inches(ppt.slide_height.inches-kBASE_BOTTOM_INCHES)height=Inches(kBASE_TOP_INCHES)left=Inches(0)top=Inches(.1)shapes.add_picture(kASSETS_DIRECTORY+"ppt_softinsa_header.png",left,top,height=height,width=ppt.slide_width)# shapes.title.text = "curriculum vitae – Resource {}".format(1)title_box=shapes.add_textbox(left=Inches(0.5),top=Inches(kBASE_TOP_INCHES*1.5),width=ppt.slide_width,height=Pt(px_to_pt(50)))title_box.text=u'Curriculum Vitae – {}'.format(user.name)info_table=shapes.add_table(rows=3,cols=2,left=Inches(.2),top=Inches(kBASE_TOP_INCHES*3),width=200,height=200).table# set table propertiesinfo_table.first_row=Falseinfo_table.horz_banding=Falseinfo_table.vert_banding=True# set column widthsinfo_table.columns[0].width=Inches(1.4)info_table.columns[1].width=Inches(3)rows_number=len(info_table.rows)user_info=user.basic_info()foriinrange(rows_number):info_table.cell(i,0).text=kINTRODUCTION_COLUMN[i]info_table.cell(i,1).text=user_info[i]# sets the font size for the content info of the tableinfo_cell=info_table.rows[i].cells[1]info_cell.text_frame.paragraphs[0].font.size=Pt(kCELL_INFO_FONT_SIZE)experiences_table=shapes.add_table(rows=2,cols=1,left=Inches(5),top=Inches(kBASE_TOP_INCHES*3),width=200,height=Inches(9.9).).table# set table dimensionsexperiences_table.columns[0].width=Inches(4.7)experiences_table.rows[0].height=Inches(kTABLE_HEADER_INCHES)# set cell font sizeexperience_title_cell=experiences_table.rows[0].cells[0]experience_cell=experiences_table.rows[1].cells[0]experience_cell.text_frame.paragraphs[0].font.size=Pt(kCELL_INFO_FONT_SIZE)# set header# "Professional Experience"experiences_table.cell(0,0).text=u"Experiência Profissional"importre

expr=re.compile(ur'- .+ até [^\n]+\n')forexperience_iteminexperience_text:ifexpr.search(experience_item):lines=experience_item.split('\n')paragraph=experiences_table.cell(1,0).text_frame.paragraphs[0]bold_run=paragraph.add_run()bold_run.font.bold=Truebold_run.text=lines[0]+'\n'rest_run=paragraph.add_run()rest_run.font.bold=Falserest_run.text='\n'.join(lines[1:])+'\n'else:experiences_table.cell(1,0).text='\n'.join(experience_text)education_table=shapes.add_table(rows=2,cols=1,left=Inches(.2),top=Inches(kBASE_TOP_INCHES*5.5),width=200,height=Inches(3.2)).table# set column widthseducation_table.columns[0].width=Inches(4.4)education_table.rows[0].height=Inches(kTABLE_HEADER_INCHES)# set header titleeducation_table.cell(0,0).text="Formação"# set font size for table infoeducation_cell=education_table.rows[1].cells[0]education_cell.text_frame.paragraphs[0].font.size=Pt(kCELL_INFO_FONT_SIZE)user_education=user.education_info()education_info=[]skills_table=shapes.add_table(rows=2,cols=1,left=Inches(.2),top=Inches(kBASE_TOP_INCHES*9.5),width=200,height=Inches(3.3)).table# set column widthsskills_table.columns[0].width=Inches(4.4)skills_table.rows[0].height=Inches(kTABLE_HEADER_INCHES)# set header titleskills_table.cell(0,0).text="Competências"# set font size for table infoskills_cell=skills_table.rows[1].cells[0]skills_cell.text_frame.paragraphs[0].font.size=Pt(kCELL_INFO_FONT_SIZE)skills_table.cell(1,0).text="".join(skills)# TODO: check if it always on object or if it can be a listforcourseinuser_education['courses']:education_info.append(u'{} de {}'.format(DEGREE_LEVELS[course['degree']]ifcourse['degree']elsecourse['degree'],course['name']))user_certifications=user_education['certifications']iflen(user_certifications)isnot0:education_info.append(u'Certificações: {}'.format(u', '.join(user_certifications)))bullets=""foriinrange(len(education_info)):bullets+=u'- {}\n'.format(education_info[i])education_table.cell(1,0).text=bullets

text_box=shapes.add_textbox(left=Inches(0),top=Inches(ppt.slide_height.inches-kBASE_BOTTOM_INCHES),width=ppt.slide_width,height=Pt(px_to_pt(50)))# text_box.text = "Proposta Nº{} - Confidencial".format("P63838/1")p=text_box.text_frame.add_paragraph()p.text=u'Confidencial'# "Proposta Nº{} - Confidencial".format("P63838/1")p.alignment=PP_PARAGRAPH_ALIGNMENT.CENTER

p.font.size=Pt(8)shapes.add_picture(kASSETS_DIRECTORY+"ppt_footer.png",left=Inches(ppt.slide_width.inches-2.5),top=Inches(ppt.slide_height.inches-(kBASE_BOTTOM_INCHES/2)),height=Pt(px_to_pt(10)),width=Pt(px_to_pt(185)))returnshapes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值