python-pptx

Extract table from Powerpoint

こ雲淡風輕ζ 提交于 2019-12-23 01:53:11
问题 I am trying to extract table from a PPT using python-pptx , however, the I am not sure how do I that using shape.table . from pptx import Presentation prs = Presentation(path_to_presentation) # text_runs will be populated with a list of strings, # one for each text run in presentation text_runs = [] for slide in prs.slides: for shape in slide.shapes: if shape.has_table: tbl = shape.table rows = tbl.rows.count cols = tbl.columns.count I found a post here but the accepted solution does not work

Python-PPTX: Changing table style or adding borders to cells

不羁的心 提交于 2019-12-22 09:08:06
问题 I've started putting together some code to take Pandas data and put it into a PowerPoint slide. The template I'm using defaults to Medium Style 2 - Accent 1 which would be fine as changing the font and background are fairly easy, but there doesn't appear to be an implemented portion to python-pptx that allows for changing cell borders. Below is my code, open to any solution. (Altering the XML or changing the template default to populate a better style would be good options for me, but haven't

Color Specific Bar Chart Differently in Python PPTX

萝らか妹 提交于 2019-12-20 02:36:29
问题 Is it possible in python-pptx to color a specific bar in a bar chart different from others? My intention is to color the bar based on values. By default, all is blue, but if the value is below certain threshold, the bar is colored red. Below is my current code with all bars colored blue-ish, rgb(65,105,225) # HUMIDITY CHART chart_data = ChartData() chart_data.categories = list(m.columns) chart_data.add_series('Humidity', list(m.loc[svc,'Humidity']), 3) graphic_frame = s.placeholders[14]

python-pptx: insert picture into content placeholder

不想你离开。 提交于 2019-12-19 04:07:21
问题 I'm using python-pptx 0.6.0 and I created a slide with content with caption. I want to insert picture into the content placeholder but there is no attribute such as add_picture or insert_picuture to use. How can I add picture into this content placeholder? Thanks for answering my question :) 回答1: See the documentation on Understanding placeholders and Working with placeholders. In brief, using something like this, you get the placeholder from the slide, then call insert_picture on the

Editing underlying PowerPoint XML with Python (python-pptx)

荒凉一梦 提交于 2019-12-14 01:16:07
问题 I have PowerPoint files with many dozens of links to different sheets in an Excel document. I need to change the Excel documents to which these links point in a programmatic way. I'm pretty sure I could do this with VBA, but since I'm generating the Excel documents in python anyway I'd prefer to update the links there as well. I dug in to the underlying XML files for a test .pptx file and found that the link references live in the ppt/slides/_rels/ folder (after unzipping the .pptx file) For

Is it possible to set two value axis in python-pptx (one left, one right)

非 Y 不嫁゛ 提交于 2019-12-13 20:24:16
问题 I frequently use python-pptx, with current version of 0.6.6.... Now I want to set up a chart with two value axis, one on the left, one on the right, just like this: In the doc of python-pptx, value_axis is accessed by chart.value_axis, but I have not found any description about how to set two value axis (with its own maximum_scale/minimum_scale/major_unit). Any clue on that? Picture with two value axis Following Scanny's answer, I dig a little bit into the lxml, but I found it do not work

get the title of slides of pptx file using Python

萝らか妹 提交于 2019-12-12 12:58:10
问题 I am trying to get the title of each slide of a powerpoint file using Python. I am using Presentation package in Python but I couldn't find anything that specifies the titles. I have this code that return the content of the powerpoint file. but I need to specify the titles. from pptx import Presentation prs = Presentation("pp.pptx") # text_runs will be populated with a list of strings, # one for each text run in presentation text_runs = [] for slide in prs.slides: for shape in slide.shapes:

Fit a Picture in PPT Placeholder

 ̄綄美尐妖づ 提交于 2019-12-11 15:53:41
问题 I want to fit an image in PPT placeholder and looked two below links: Similar Question Similar Query From the similar question, I have applied the solution but it is still showing cropped image in the ppt. My code for the same: prs = Presentation(path) title_slide_layout = prs.slide_layouts[4] ## Changed the content to picture as I need two pictures in one slide pic_placeholder = slide.placeholders[15] ## The two picture placeholders pic_placeholder1 = slide.placeholders[16] print(pic

Print Powerpoint slide with python-pptx

一世执手 提交于 2019-12-11 10:38:47
问题 I've been using python-pptx to access slides (I find it much smoother than using win32 as it doesn't need to open the Powerpoint window. However, I've checked the docs but can't find any method of printing a slide. Am I missing something? Here is what I have so far: from pptx import Presentation prs = Presentation(path) for slide in prs.slides: if slide.name == slide_I_want: #send slide to printer 回答1: python-pptx (purposely) does not have a PowerPoint renderer, and so cannot print slides

How to keep original text formatting of text with python powerpoint?

放肆的年华 提交于 2019-12-11 09:27:52
问题 I'd like to update the text within a textbox without changing the formatting. In other words, I'd like to keep the original formatting of the original text while changing that text I can update the text with the following, but the formatting is changed completely in the process. from pptx import Presentation prs = Presentation("C:\\original_powerpoint.pptx") sh = prs.slides[0].shapes[0] sh.text_frame.paragraphs[0].text = 'MY NEW TEXT' prs.save("C:\\new_powerpoint.pptx") How can I update the