'How to import data from csv file and paste to ppt table using pptx?
I am trying to import data from a csv file and loaded to ppt table using pptx. The number of columns are fixed but the number of rows can be varies depends on the condition. The number of rows can be up to hundreds.
Is there a easy way to create table in ppt using pptx in Python?
Sample data:
Name Contract No. Start_Date Total Delivered Ready
A 220104 2022-02-03 10 5 2
B 220104 2022-02-03 5 3 2
C 220104 2022-02-03 13 12 3
D 220104 2022-02-03 12 3 4
E 220104 2022-02-03 15 8 3
... .... .... .. .. ..
... .... .... .. .. ..
... .... .... .. .. ..
Here is the code I've got so far.
template = prs.slide_layouts[2]
slide.prs.slides.add_slide(template)
path_order_tbl = os.path.join(path_data, f'df.csv')
if os.path.exists(path_order_tbl):
df_order = pd.read_csv(path_order_tbl)
x, y, cx, cy = Inches(2), Inches(2), Inches(4), Inches(1.5)
shape.slide.shapes.add_table(6,20,x,x,cx,cy)
table = shape.table
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
