Questions tagged [python-pptx]

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

Latest documentation

Available from pypi.

734 questions
3
votes
1 answer

how to change title color in python pptx

from pptx import Presentation from pptx.dml.color import RGBColor prs=Presentation() title_slide_layout=prs.slide_layouts[0] slide=prs.slides.add_slide(title_slide_layout) background=slide.background fill =…
KEYAN TECH
  • 105
  • 1
  • 8
3
votes
1 answer

XL_CHART_TYPE.DOUGHNUT set hole size

I'm trying to make doughnut chart with python-pptx. I need to set custom hole size, and it should be holeSize attribute, but i can't find it. Can anybody help me? chart = ph.insert_chart(XL_CHART_TYPE.DOUGHNUT, chart_data).chart s =…
Valeria
  • 33
  • 4
3
votes
3 answers

Python-PPTX : Data Label Positions not working for Doughnut Chart

I have a Chart Placeholder, into which I have inserted a chart of chart_type 'DOUGHNUT'. I've added data labels to it and want to change their positions. For some reason, the method given in the documentation has no effect on my chart. Here is my…
Utkarsh Sinha
  • 941
  • 2
  • 11
  • 30
3
votes
1 answer

python-pptx color legend not showing same colors as graph

This drives me nuts. chart_AllData = slideref.shapes.add_chart(XL_CHART_TYPE.BAR_STACKED_100, x, y, cx, cy, chart_data) chart = chart_AllData.chart plot = chart.plots[0] pointCount = 0 for answer in…
Bengt Berg
  • 41
  • 1
3
votes
2 answers

Unable to insert picture in slide

I am trying to read pictures from the file and inserting them into the slide. So far its working fine. But today its giving me an error : "'Image' object has no attribute '_ext'". I can see that image is same as other images and it is a .jpg image.…
Gowtham
  • 131
  • 2
  • 12
3
votes
1 answer

Python PPTX: How to Update or Replace a Chart Series?

Python PPTX: How to update or Replace a Chart Series? I'm getting KeyError: 'rId2' on this line: FSShapeChart.replace_data(chart_data) here is more code: prs = Presentation(self.PowerPointTemplatePath) FirstSlide = prs.slides[0] FSShapeChart =…
Mattman85208
  • 1,858
  • 2
  • 29
  • 51
3
votes
1 answer

Python PPTX - How to set chart axis number format and range

I'm trying to accommodate a Bar Chart Y axis with a range from 0 to 1 with 1 decimal place like: 1.2 for tick labels: I can set it to start at 0 with: Thisvalue_axis.minimum_scale = 0 And I can set the top value with: Thisvalue_axis.major_unit =…
Mattman85208
  • 1,858
  • 2
  • 29
  • 51
3
votes
1 answer

python-pptx font size from hierarchy / template / master

[text element].font.size returns None if the element has inherited its size from a parent text style. The documentation refers to a style hierarchy but doesn't appear to include documentation about it. Does anyone know how you traverse this…
3
votes
1 answer

How to change indent on bulleted list on PPT slide using pptx python library

I have started using 'pptx' library to programmatically generate some PPT based report. We have a company template which I am using as a base. It contains a master slide with bulleted list in single column format which looks like this (but with…
jayS
  • 168
  • 8
3
votes
1 answer

Python pptx - How to set bullet points and top alignment

How can I set the text to Top (there is a a first line in standard body formating set upfront) and it is not set to TOP alignment ? Add_paragraph function did not activate the fist bullet points level (level = 0)? Someone got an idea on how to solve…
otluk
  • 317
  • 1
  • 4
  • 16
3
votes
3 answers

How do you set the font size of a Chart Title with Python PPTX?

I add a chart with: doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (PerformancePercent, NotPerformedPercent)) This gives me a chart title with the text, but how do I change the font size? This: ThisDoughnutChart.title.font.size =…
Mattman85208
  • 1,858
  • 2
  • 29
  • 51
3
votes
3 answers

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

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…
Chris
  • 5,444
  • 16
  • 63
  • 119
3
votes
2 answers

How does one define , extract and replace data from a Chart in an existing Powerpoint using Python

Currently I am using the following code to define and replace Placeholder (Text data) in existing Powerpoint presentations. current_dir = os.path.dirname(os.path.realpath(__file__)) prs = Presentation(current_dir + '/test2.pptx') slides =…
MattDM
  • 31
  • 3
3
votes
1 answer

Python PPTX workaround function for rotating chart data labels

I intend to create the following chart using Python PPTX. Below code achieve the color setting, font size and number format. However, I am not yet able to rotate the data label, as I believe this API is not yet available in python-pptx 0.6.5 lbl =…
idazuwaika
  • 2,749
  • 7
  • 38
  • 46
3
votes
3 answers

Python PPTX Bar Chart negative values

I use the following code to give specific color for the bars, for a bar chart generated by python-pptx. chart.series[0].format.fill.solid() chart.series[0].format.fill.fore_color.rgb = RGBColor(160,190,230) This looks fine most of time. However,…
idazuwaika
  • 2,749
  • 7
  • 38
  • 46