Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
Đọc is library used to create/edit a PowerPoint [.pptx] files. This won’t work on MS office 2003 and previous versions. We can add shapes, paragraphs, texts and slides and much more thing using this library.
Bàn luận Open the command prompt on your system and write given below command:
pip install python-pptx
Python-PPTX là thư viện được sử dụng để tạo/chỉnh sửa các tệp PowerPoint [.pptx]. Điều này đã giành được công việc trên MS Office 2003 và các phiên bản trước. & nbsp; chúng ta có thể thêm hình dạng, đoạn văn, văn bản và slide và nhiều thứ khác bằng thư viện này.
Cài đặt: Mở dấu nhắc lệnh trên hệ thống của bạn và ghi lệnh dưới đây: Creating new PowerPoint file with title and subtitle slide.
Python3
Hãy cùng xem một số cách sử dụng của nó:
Ví dụ 1: Tạo tệp PowerPoint mới với Slide tiêu đề và phụ đề.
from
pptx
import
Presentation
root
=
Presentation[]
first_slide_layout
=
from
0from
1from
2
from
3=
from
5
pptx
4pptx
5pptx
6
pptx
7pptx
8pptx
9pptx
6
Output:
from
6=
from
8Adding Text-Box in PowerPoint.
Python3
from
9pptx
0pptx
1=
pptx
3
Ví dụ 2: Thêm hộp văn bản trong PowerPoint.
from
pptx
import
import
4
from
import
6import
import
8
import
9=
Presentation
1
Presentation
2=
Presentation
4Presentation
5from
2
from
3=
Presentation
9
=
4=
5
root
0=
root
2=
root
4=
root
6=
=
1=
=
3
=
6=
=
8
=
9=
Presentation[]
1
Presentation[]
2=
Presentation[]
4
Presentation[]
5=
________ 77 & nbsp;
Presentation[]
8=
first_slide_layout
0
first_slide_layout
1=
first_slide_layout
0
Presentation[]
2=
first_slide_layout
6
=
5=
6pptx
6
pptx
7pptx
8pptx
9pptx
6
Output:
Presentation[]
5=
________ 89 & nbsp; PowerPoint [.pptx] file to Text [.txt] file conversion.
Python3
=
0=
=
2=
3pptx
6
Ví dụ 3: Chuyển đổi tệp PowerPoint [.pptx] sang Text [.txt].
from
pptx
import
from
05
import
9=
from
08from
09pptx
6
from
11=
from
13pptx
8from
15from
16from
17pptx
6
from
19 from
3from
21 from
22
from
32from
33
from
23from
19 from
25from
21 from
27
from
28from
29 from
30 from
31
from
44from
45
from
46
from
28from
19 from
36from
21 from
38
Output:
from
32from
19 from
41from
21 from
43 Inserting image into the PowerPoint file.
Python3
from
9pptx
0pptx
1=
pptx
3
Ví dụ 2: Thêm hộp văn bản trong PowerPoint.
from
pptx
import
import
4
from
pptx
import
import
4
from
import
6import
import
8
import
9=
Presentation
1
Presentation
2=
Presentation
4Presentation
5from
2
from
3=
Presentation
9
from
83from
84
root
0=
root
2=
root
4=
root
6=
=
1=
=
3
=
6=
=
8
=
9=
Presentation[]
1
=
5pptx
03pptx
6
pptx
7pptx
8from
49pptx
6
Output:
Presentation[]
2=
Presentation[]
4 Adding Charts to the PowerPoint file.
Python3
from
9pptx
0pptx
1=
pptx
3
Ví dụ 2: Thêm hộp văn bản trong PowerPoint.
from
pptx
import
import
4
from
import
6import
import
8
from
pptx
import
import
4
from
import
6import
import
8
import
9=
Presentation
1
Presentation
2=
Presentation
4Presentation
5from
2
pptx
45pptx
46pptx
47
pptx
48pptx
8pptx
50pptx
8pptx
52pptx
8pptx
54pptx
55
pptx
56pptx
50pptx
8pptx
52pptx
8pptx
54pptx
62
pptx
56pptx
50pptx
8pptx
52pptx
8pptx
54pptx
69
from
3=
Presentation
9
pptx
81
pptx
82pptx
83
=
5pptx
85pptx
6
pptx
7pptx
8pptx
9pptx
6
Output:
root
0=
root
2=
root
4=
root
6=
Adding tables to the PowerPoint file.
Python3
from
9pptx
0pptx
1=
pptx
3
from
import
6import
import
8
from
pptx
import
import
4
from
import
6import
import
8
import
9=
Presentation
1
Presentation
2=
Presentation
4Presentation
5from
2
from
83import
26
=
5import
28pptx
6
from
3=
Presentation
9
Output: