888 lines
32 KiB
Python
888 lines
32 KiB
Python
"""
|
|
Script pour créer des fichiers exemples avec structure TRÈS COMPLEXE
|
|
Génère des fichiers Excel, Word et PowerPoint avec formatage avancé
|
|
"""
|
|
from pathlib import Path
|
|
from openpyxl import Workbook
|
|
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side, Protection
|
|
from openpyxl.styles.numbers import FORMAT_CURRENCY_USD, FORMAT_PERCENTAGE
|
|
from openpyxl.chart import BarChart, PieChart, LineChart, Reference
|
|
from openpyxl.drawing.image import Image as XLImage
|
|
from openpyxl.utils import get_column_letter
|
|
from openpyxl.worksheet.datavalidation import DataValidation
|
|
|
|
from docx import Document
|
|
from docx.shared import Inches, Pt, RGBColor, Cm
|
|
from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING
|
|
from docx.enum.style import WD_STYLE_TYPE
|
|
from docx.oxml.ns import qn
|
|
from docx.oxml import OxmlElement
|
|
|
|
from pptx import Presentation
|
|
from pptx.util import Inches as PptxInches, Pt as PptxPt
|
|
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
|
|
from pptx.dml.color import RGBColor as PptxRGBColor
|
|
from pptx.enum.shapes import MSO_SHAPE
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
print("🚀 Création de fichiers exemples avec structure COMPLEXE...\n")
|
|
|
|
# Créer le dossier
|
|
SAMPLE_DIR = Path("sample_files")
|
|
SAMPLE_DIR.mkdir(exist_ok=True)
|
|
|
|
# ============================================================================
|
|
# 1. EXCEL TRÈS COMPLEXE
|
|
# ============================================================================
|
|
print("📊 Création d'Excel super complexe...")
|
|
|
|
wb = Workbook()
|
|
|
|
# === SHEET 1: RAPPORT FINANCIER COMPLEXE ===
|
|
ws1 = wb.active
|
|
ws1.title = "Rapport Financier 2024"
|
|
|
|
# Titre principal avec fusion massive
|
|
ws1.merge_cells('A1:H2')
|
|
title = ws1['A1']
|
|
title.value = "RAPPORT FINANCIER ANNUEL 2024\nAnalyse Complète et Prévisions"
|
|
title.font = Font(name='Calibri', size=20, bold=True, color='FFFFFF')
|
|
title.fill = PatternFill(start_color='0066CC', end_color='0066CC', fill_type='solid')
|
|
title.alignment = Alignment(horizontal='center', vertical='center', wrap_text=True)
|
|
title.border = Border(
|
|
left=Side(style='thick', color='000000'),
|
|
right=Side(style='thick', color='000000'),
|
|
top=Side(style='thick', color='000000'),
|
|
bottom=Side(style='thick', color='000000')
|
|
)
|
|
|
|
# Sous-titre avec fusion
|
|
ws1.merge_cells('A3:H3')
|
|
subtitle = ws1['A3']
|
|
subtitle.value = "Département des Ventes - Trimestre Q1-Q4"
|
|
subtitle.font = Font(size=14, italic=True, color='0066CC')
|
|
subtitle.alignment = Alignment(horizontal='center')
|
|
|
|
# En-têtes de colonnes avec style élaboré
|
|
headers = ['Région', 'Produit', 'Unités Vendues', 'Prix Unitaire', 'Chiffre d\'Affaires', 'Coût', 'Marge Brute', 'Marge %']
|
|
for col, header in enumerate(headers, 1):
|
|
cell = ws1.cell(row=4, column=col)
|
|
cell.value = header
|
|
cell.font = Font(bold=True, color='FFFFFF', size=12)
|
|
cell.fill = PatternFill(start_color='0066CC', end_color='0066CC', fill_type='solid')
|
|
cell.alignment = Alignment(horizontal='center', vertical='center', wrap_text=True)
|
|
cell.border = Border(
|
|
left=Side(style='thin'),
|
|
right=Side(style='thin'),
|
|
top=Side(style='thin'),
|
|
bottom=Side(style='thin')
|
|
)
|
|
|
|
# Données complexes avec formules avancées
|
|
regions = ['Europe du Nord', 'Europe du Sud', 'Amérique du Nord', 'Amérique du Sud', 'Asie Pacifique', 'Moyen-Orient', 'Afrique']
|
|
products = ['Ordinateur Portable Premium', 'Tablette Professionnelle', 'Smartphone 5G', 'Écran 4K', 'Casque Sans Fil']
|
|
|
|
row = 5
|
|
for region in regions:
|
|
for i, product in enumerate(products):
|
|
units = 100 + (row * 13) % 500
|
|
price = 299 + (row * 37) % 1200
|
|
cost = price * 0.6
|
|
|
|
ws1.cell(row=row, column=1, value=region)
|
|
ws1.cell(row=row, column=2, value=product)
|
|
ws1.cell(row=row, column=3, value=units)
|
|
ws1.cell(row=row, column=4, value=price).number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Formule: Chiffre d'affaires
|
|
ws1.cell(row=row, column=5, value=f"=C{row}*D{row}").number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Coût
|
|
ws1.cell(row=row, column=6, value=cost).number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Formule: Marge brute
|
|
ws1.cell(row=row, column=7, value=f"=E{row}-F{row}").number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Formule: Marge %
|
|
ws1.cell(row=row, column=8, value=f"=IF(E{row}>0,G{row}/E{row},0)").number_format = FORMAT_PERCENTAGE
|
|
|
|
# Formatage conditionnel par région
|
|
for col in range(1, 9):
|
|
cell = ws1.cell(row=row, column=col)
|
|
if row % 2 == 0:
|
|
cell.fill = PatternFill(start_color='F2F2F2', end_color='F2F2F2', fill_type='solid')
|
|
cell.border = Border(
|
|
left=Side(style='thin', color='CCCCCC'),
|
|
right=Side(style='thin', color='CCCCCC'),
|
|
top=Side(style='thin', color='CCCCCC'),
|
|
bottom=Side(style='thin', color='CCCCCC')
|
|
)
|
|
|
|
row += 1
|
|
|
|
# Ligne de total avec formules complexes
|
|
total_row = row + 1
|
|
ws1.merge_cells(f'A{total_row}:B{total_row}')
|
|
total_cell = ws1[f'A{total_row}']
|
|
total_cell.value = "TOTAL GÉNÉRAL"
|
|
total_cell.font = Font(bold=True, size=14, color='FFFFFF')
|
|
total_cell.fill = PatternFill(start_color='FF6600', end_color='FF6600', fill_type='solid')
|
|
total_cell.alignment = Alignment(horizontal='right', vertical='center')
|
|
|
|
for col in [3, 5, 7]:
|
|
cell = ws1.cell(row=total_row, column=col)
|
|
cell.value = f"=SUM({get_column_letter(col)}5:{get_column_letter(col)}{row-1})"
|
|
cell.font = Font(bold=True, size=12)
|
|
cell.fill = PatternFill(start_color='FF6600', end_color='FF6600', fill_type='solid')
|
|
if col in [5, 7]:
|
|
cell.number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Marge % moyenne
|
|
avg_cell = ws1.cell(row=total_row, column=8)
|
|
avg_cell.value = f"=AVERAGE(H5:H{row-1})"
|
|
avg_cell.number_format = FORMAT_PERCENTAGE
|
|
avg_cell.font = Font(bold=True, size=12)
|
|
avg_cell.fill = PatternFill(start_color='FF6600', end_color='FF6600', fill_type='solid')
|
|
|
|
# Ajuster les largeurs
|
|
ws1.column_dimensions['A'].width = 20
|
|
ws1.column_dimensions['B'].width = 30
|
|
ws1.column_dimensions['C'].width = 15
|
|
ws1.column_dimensions['D'].width = 15
|
|
ws1.column_dimensions['E'].width = 18
|
|
ws1.column_dimensions['F'].width = 15
|
|
ws1.column_dimensions['G'].width = 15
|
|
ws1.column_dimensions['H'].width = 12
|
|
|
|
# === SHEET 2: GRAPHIQUES ET ANALYSES ===
|
|
ws2 = wb.create_sheet("Analyses Graphiques")
|
|
|
|
ws2['A1'] = "Analyse des Performances par Région"
|
|
ws2['A1'].font = Font(size=16, bold=True, color='0066CC')
|
|
ws2.merge_cells('A1:D1')
|
|
|
|
# Données pour graphiques
|
|
ws2['A3'] = "Région"
|
|
ws2['B3'] = "Total Ventes"
|
|
ws2['C3'] = "Objectif"
|
|
ws2['D3'] = "Écart %"
|
|
|
|
region_data = [
|
|
("Europe", 2500000, 2200000),
|
|
("Amérique", 3200000, 3000000),
|
|
("Asie", 2800000, 2900000),
|
|
("Autres", 1200000, 1100000)
|
|
]
|
|
|
|
for i, (region, sales, target) in enumerate(region_data, 4):
|
|
ws2.cell(row=i, column=1, value=region)
|
|
ws2.cell(row=i, column=2, value=sales).number_format = FORMAT_CURRENCY_USD
|
|
ws2.cell(row=i, column=3, value=target).number_format = FORMAT_CURRENCY_USD
|
|
ws2.cell(row=i, column=4, value=f"=(B{i}-C{i})/C{i}").number_format = FORMAT_PERCENTAGE
|
|
|
|
# Graphique en barres
|
|
chart1 = BarChart()
|
|
chart1.title = "Ventes par Région vs Objectifs"
|
|
chart1.y_axis.title = "Montant (USD)"
|
|
chart1.x_axis.title = "Régions"
|
|
chart1.height = 10
|
|
chart1.width = 20
|
|
|
|
data = Reference(ws2, min_col=2, min_row=3, max_row=7, max_col=3)
|
|
cats = Reference(ws2, min_col=1, min_row=4, max_row=7)
|
|
chart1.add_data(data, titles_from_data=True)
|
|
chart1.set_categories(cats)
|
|
ws2.add_chart(chart1, "F3")
|
|
|
|
# Graphique circulaire
|
|
chart2 = PieChart()
|
|
chart2.title = "Répartition des Ventes par Région"
|
|
chart2.height = 10
|
|
chart2.width = 15
|
|
|
|
data2 = Reference(ws2, min_col=2, min_row=4, max_row=7)
|
|
cats2 = Reference(ws2, min_col=1, min_row=4, max_row=7)
|
|
chart2.add_data(data2)
|
|
chart2.set_categories(cats2)
|
|
ws2.add_chart(chart2, "F20")
|
|
|
|
# === SHEET 3: DONNÉES MENSUELLES AVEC TENDANCES ===
|
|
ws3 = wb.create_sheet("Tendances Mensuelles")
|
|
|
|
ws3['A1'] = "Évolution Mensuelle des Ventes 2024"
|
|
ws3['A1'].font = Font(size=16, bold=True, color='FF6600')
|
|
ws3.merge_cells('A1:M1')
|
|
|
|
months = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']
|
|
ws3['A3'] = "Mois"
|
|
for i, month in enumerate(months, 2):
|
|
ws3.cell(row=3, column=i, value=month)
|
|
ws3.cell(row=3, column=i).font = Font(bold=True)
|
|
|
|
# Produits avec ventes mensuelles
|
|
products_monthly = ['Laptops', 'Tablettes', 'Smartphones', 'Accessoires']
|
|
for i, product in enumerate(products_monthly, 4):
|
|
ws3.cell(row=i, column=1, value=product)
|
|
ws3.cell(row=i, column=1).font = Font(bold=True)
|
|
|
|
for month_col in range(2, 14):
|
|
value = 50000 + (i * month_col * 1234) % 30000
|
|
ws3.cell(row=i, column=month_col, value=value).number_format = FORMAT_CURRENCY_USD
|
|
|
|
# Ligne de total avec formule
|
|
ws3.cell(row=8, column=1, value="TOTAL")
|
|
ws3.cell(row=8, column=1).font = Font(bold=True, size=12)
|
|
for col in range(2, 14):
|
|
ws3.cell(row=8, column=col, value=f"=SUM({get_column_letter(col)}4:{get_column_letter(col)}7)")
|
|
ws3.cell(row=8, column=col).number_format = FORMAT_CURRENCY_USD
|
|
ws3.cell(row=8, column=col).font = Font(bold=True)
|
|
ws3.cell(row=8, column=col).fill = PatternFill(start_color='FFD700', end_color='FFD700', fill_type='solid')
|
|
|
|
# Graphique linéaire
|
|
chart3 = LineChart()
|
|
chart3.title = "Tendance des Ventes sur 12 Mois"
|
|
chart3.y_axis.title = "Montant (USD)"
|
|
chart3.x_axis.title = "Mois"
|
|
chart3.height = 12
|
|
chart3.width = 24
|
|
|
|
data3 = Reference(ws3, min_col=2, min_row=3, max_row=8, max_col=13)
|
|
cats3 = Reference(ws3, min_col=2, min_row=3, max_col=13)
|
|
chart3.add_data(data3, titles_from_data=True)
|
|
chart3.set_categories(cats3)
|
|
ws3.add_chart(chart3, "A10")
|
|
|
|
# Sauvegarder Excel
|
|
excel_file = SAMPLE_DIR / "super_complex.xlsx"
|
|
wb.save(excel_file)
|
|
print(f"✅ Excel créé: {excel_file}")
|
|
print(f" - 3 feuilles avec données complexes")
|
|
print(f" - Cellules fusionnées multiples")
|
|
print(f" - Formules avancées (SUM, AVERAGE, IF, pourcentages)")
|
|
print(f" - 3 graphiques (barres, camembert, lignes)")
|
|
print(f" - Formatage conditionnel élaboré")
|
|
print(f" - {len(regions) * len(products)} lignes de données\n")
|
|
|
|
# ============================================================================
|
|
# 2. WORD TRÈS COMPLEXE
|
|
# ============================================================================
|
|
print("📝 Création de Word super complexe...")
|
|
|
|
doc = Document()
|
|
|
|
# Configurer les marges
|
|
sections = doc.sections
|
|
for section in sections:
|
|
section.top_margin = Cm(2)
|
|
section.bottom_margin = Cm(2)
|
|
section.left_margin = Cm(2.5)
|
|
section.right_margin = Cm(2.5)
|
|
|
|
# PAGE DE COUVERTURE
|
|
title = doc.add_heading('RAPPORT STRATÉGIQUE ANNUEL', 0)
|
|
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
for run in title.runs:
|
|
run.font.size = Pt(28)
|
|
run.font.color.rgb = RGBColor(0, 102, 204)
|
|
run.font.bold = True
|
|
|
|
subtitle = doc.add_paragraph('Analyse Complète des Performances et Perspectives 2024-2025')
|
|
subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
subtitle.runs[0].font.size = Pt(16)
|
|
subtitle.runs[0].font.italic = True
|
|
subtitle.runs[0].font.color.rgb = RGBColor(102, 102, 102)
|
|
|
|
doc.add_paragraph('\n' * 3)
|
|
|
|
company_info = doc.add_paragraph()
|
|
company_info.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
company_info.add_run('Société: TechnoVision International\n').font.size = Pt(14)
|
|
company_info.add_run('Département: Analyse Stratégique\n').font.size = Pt(12)
|
|
company_info.add_run('Date: 31 Décembre 2024').font.size = Pt(12)
|
|
|
|
doc.add_page_break()
|
|
|
|
# TABLE DES MATIÈRES
|
|
doc.add_heading('Table des Matières', 1)
|
|
toc_items = [
|
|
'1. Résumé Exécutif',
|
|
'2. Analyse des Performances Financières',
|
|
'3. Objectifs Stratégiques',
|
|
'4. Analyse de Marché',
|
|
'5. Recommandations',
|
|
'6. Conclusion'
|
|
]
|
|
for item in toc_items:
|
|
p = doc.add_paragraph(item, style='List Number')
|
|
p.runs[0].font.size = Pt(12)
|
|
|
|
doc.add_page_break()
|
|
|
|
# SECTION 1: RÉSUMÉ EXÉCUTIF
|
|
doc.add_heading('1. Résumé Exécutif', 1)
|
|
|
|
para1 = doc.add_paragraph()
|
|
para1.add_run('Ce rapport présente une analyse détaillée ').font.size = Pt(11)
|
|
para1.add_run('des performances exceptionnelles').bold = True
|
|
para1.add_run(' de notre entreprise au cours de l\'année 2024. ').font.size = Pt(11)
|
|
para1.add_run('Nous avons atteint et dépassé').italic = True
|
|
para1.add_run(' nos objectifs dans tous les domaines clés.').font.size = Pt(11)
|
|
para1.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
|
|
doc.add_heading('Points Clés', 2)
|
|
key_points = [
|
|
'Croissance du chiffre d\'affaires de 28% par rapport à 2023',
|
|
'Expansion réussie dans 5 nouveaux marchés internationaux',
|
|
'Lancement de 8 produits innovants avec taux d\'adoption de 87%',
|
|
'Amélioration de la satisfaction client: score de 4.8/5',
|
|
'Réduction de l\'empreinte carbone de 22%',
|
|
'Augmentation de la part de marché de 3.5 points'
|
|
]
|
|
|
|
for point in key_points:
|
|
p = doc.add_paragraph(point, style='List Bullet')
|
|
p.runs[0].font.size = Pt(11)
|
|
|
|
# Créer graphique pour Word
|
|
img_path = SAMPLE_DIR / "word_performance_chart.png"
|
|
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
|
|
|
|
# Graphique 1: Croissance trimestrielle
|
|
quarters = ['Q1', 'Q2', 'Q3', 'Q4']
|
|
revenue = [45.2, 52.8, 61.5, 68.3]
|
|
ax1.plot(quarters, revenue, marker='o', linewidth=2, markersize=8, color='#0066CC')
|
|
ax1.fill_between(range(len(quarters)), revenue, alpha=0.3, color='#0066CC')
|
|
ax1.set_title('Croissance Trimestrielle du CA (M€)', fontsize=14, fontweight='bold')
|
|
ax1.set_ylabel('Chiffre d\'Affaires (M€)', fontsize=11)
|
|
ax1.grid(True, alpha=0.3)
|
|
|
|
# Graphique 2: Répartition des revenus
|
|
categories = ['Produits', 'Services', 'Licences', 'Consulting']
|
|
values = [45, 25, 20, 10]
|
|
colors = ['#0066CC', '#FF6600', '#00CC66', '#CC00CC']
|
|
ax2.pie(values, labels=categories, autopct='%1.1f%%', colors=colors, startangle=90)
|
|
ax2.set_title('Répartition des Revenus 2024', fontsize=14, fontweight='bold')
|
|
|
|
plt.tight_layout()
|
|
plt.savefig(img_path, dpi=150, bbox_inches='tight')
|
|
plt.close()
|
|
|
|
doc.add_paragraph()
|
|
doc.add_picture(str(img_path), width=Inches(6))
|
|
last_paragraph = doc.paragraphs[-1]
|
|
last_paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
|
|
# SECTION 2: ANALYSE FINANCIÈRE
|
|
doc.add_page_break()
|
|
doc.add_heading('2. Analyse des Performances Financières', 1)
|
|
|
|
doc.add_heading('2.1 Résultats par Trimestre', 2)
|
|
|
|
# Tableau complexe des résultats
|
|
table = doc.add_table(rows=6, cols=6)
|
|
table.style = 'Medium Grid 3 Accent 1'
|
|
|
|
# En-têtes
|
|
headers = ['Trimestre', 'Revenus (M€)', 'Coûts (M€)', 'Marge Brute', 'Marge %', 'Croissance']
|
|
for i, header in enumerate(headers):
|
|
cell = table.rows[0].cells[i]
|
|
cell.text = header
|
|
cell.paragraphs[0].runs[0].font.bold = True
|
|
cell.paragraphs[0].runs[0].font.size = Pt(10)
|
|
|
|
# Données trimestrielles
|
|
quarterly_data = [
|
|
('Q1 2024', 45.2, 28.5, 16.7, '36.9%', '+8.5%'),
|
|
('Q2 2024', 52.8, 32.1, 20.7, '39.2%', '+16.8%'),
|
|
('Q3 2024', 61.5, 36.8, 24.7, '40.2%', '+16.5%'),
|
|
('Q4 2024', 68.3, 40.2, 28.1, '41.1%', '+11.1%'),
|
|
('TOTAL', 227.8, 137.6, 90.2, '39.6%', '28.0%')
|
|
]
|
|
|
|
for row_idx, row_data in enumerate(quarterly_data, 1):
|
|
for col_idx, value in enumerate(row_data):
|
|
cell = table.rows[row_idx].cells[col_idx]
|
|
cell.text = str(value)
|
|
if row_idx == 5: # Ligne total
|
|
cell.paragraphs[0].runs[0].font.bold = True
|
|
# Colorer le fond (workaround via XML)
|
|
shading_elm = OxmlElement('w:shd')
|
|
shading_elm.set(qn('w:fill'), 'FFD700')
|
|
cell._element.get_or_add_tcPr().append(shading_elm)
|
|
|
|
doc.add_paragraph()
|
|
|
|
doc.add_heading('2.2 Analyse Comparative', 2)
|
|
|
|
comparison_text = doc.add_paragraph()
|
|
comparison_text.add_run('Comparaison avec les objectifs annuels: ').bold = True
|
|
comparison_text.add_run('Notre performance a dépassé les objectifs fixés de ')
|
|
comparison_text.add_run('13.5%').bold = True
|
|
comparison_text.add_run(', démontrant une excellente exécution stratégique et une adaptation réussie aux conditions du marché.')
|
|
comparison_text.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
|
|
# SECTION 3: OBJECTIFS STRATÉGIQUES
|
|
doc.add_page_break()
|
|
doc.add_heading('3. Objectifs Stratégiques 2025', 1)
|
|
|
|
doc.add_heading('3.1 Vision et Mission', 2)
|
|
vision = doc.add_paragraph()
|
|
vision.add_run('Vision: ').bold = True
|
|
vision.add_run('Devenir le leader mondial dans notre secteur d\'ici 2027.')
|
|
vision.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
|
|
mission = doc.add_paragraph()
|
|
mission.add_run('Mission: ').bold = True
|
|
mission.add_run('Fournir des solutions innovantes qui transforment les entreprises et améliorent la vie de millions de personnes.')
|
|
mission.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
|
|
doc.add_heading('3.2 Objectifs Prioritaires', 2)
|
|
|
|
objectives = [
|
|
('Expansion Géographique', 'Pénétrer 10 nouveaux marchés en Asie et Europe de l\'Est'),
|
|
('Innovation Produit', 'Lancer 12 nouveaux produits avec IA intégrée'),
|
|
('Excellence Opérationnelle', 'Réduire les coûts de 15% via automatisation'),
|
|
('Satisfaction Client', 'Atteindre un NPS de 75+'),
|
|
('Développement Durable', 'Neutralité carbone d\'ici fin 2025')
|
|
]
|
|
|
|
for i, (title, desc) in enumerate(objectives, 1):
|
|
p = doc.add_paragraph(style='List Number')
|
|
p.add_run(f'{title}: ').bold = True
|
|
p.add_run(desc)
|
|
|
|
# Ajouter une image conceptuelle
|
|
concept_img = SAMPLE_DIR / "word_strategy_image.png"
|
|
img = Image.new('RGB', (800, 400), color=(240, 248, 255))
|
|
draw = ImageDraw.Draw(img)
|
|
try:
|
|
font_large = ImageFont.truetype("arial.ttf", 60)
|
|
font_small = ImageFont.truetype("arial.ttf", 30)
|
|
except:
|
|
font_large = ImageFont.load_default()
|
|
font_small = ImageFont.load_default()
|
|
|
|
draw.rectangle([50, 50, 750, 350], outline=(0, 102, 204), width=5, fill=(230, 240, 255))
|
|
draw.text((400, 150), "STRATÉGIE 2025", fill=(0, 102, 204), font=font_large, anchor="mm")
|
|
draw.text((400, 250), "Innovation • Excellence • Croissance", fill=(102, 102, 102), font=font_small, anchor="mm")
|
|
img.save(concept_img)
|
|
|
|
doc.add_paragraph()
|
|
doc.add_picture(str(concept_img), width=Inches(5.5))
|
|
doc.paragraphs[-1].alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
|
|
# CONCLUSION
|
|
doc.add_page_break()
|
|
doc.add_heading('6. Conclusion', 1)
|
|
|
|
conclusion = doc.add_paragraph()
|
|
conclusion.add_run('L\'année 2024 a été exceptionnelle ').font.size = Pt(12)
|
|
conclusion.add_run('pour notre organisation. ').bold = True
|
|
conclusion.add_run('Nous avons non seulement atteint nos objectifs ambitieux, mais nous avons également posé les bases solides pour une croissance continue et durable. ')
|
|
conclusion.add_run('L\'engagement de nos équipes, la confiance de nos clients et l\'innovation de nos produits ').italic = True
|
|
conclusion.add_run('sont les piliers de notre succès.')
|
|
conclusion.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
conclusion.paragraph_format.line_spacing_rule = WD_LINE_SPACING.MULTIPLE
|
|
conclusion.paragraph_format.line_spacing = 1.5
|
|
|
|
# Footer
|
|
section = doc.sections[0]
|
|
footer = section.footer
|
|
footer_para = footer.paragraphs[0]
|
|
footer_para.text = "Document Confidentiel - TechnoVision International 2024 | "
|
|
footer_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
|
footer_para.runs[0].font.size = Pt(9)
|
|
footer_para.runs[0].font.italic = True
|
|
|
|
# Sauvegarder Word
|
|
word_file = SAMPLE_DIR / "super_complex.docx"
|
|
doc.save(word_file)
|
|
print(f"✅ Word créé: {word_file}")
|
|
print(f" - 6 sections structurées")
|
|
print(f" - Page de couverture professionnelle")
|
|
print(f" - Table des matières")
|
|
print(f" - Tableaux complexes avec formatage")
|
|
print(f" - 3 images intégrées (graphiques et concepts)")
|
|
print(f" - Formatage avancé (styles, couleurs, alignements)")
|
|
print(f" - Pieds de page\n")
|
|
|
|
# ============================================================================
|
|
# 3. POWERPOINT TRÈS COMPLEXE
|
|
# ============================================================================
|
|
print("🎨 Création de PowerPoint super complexe...")
|
|
|
|
prs = Presentation()
|
|
prs.slide_width = PptxInches(10)
|
|
prs.slide_height = PptxInches(7.5)
|
|
|
|
# SLIDE 1: TITRE PRINCIPAL
|
|
slide1 = prs.slides.add_slide(prs.slide_layouts[6]) # Blank
|
|
|
|
# Fond coloré
|
|
background = slide1.shapes.add_shape(
|
|
MSO_SHAPE.RECTANGLE,
|
|
0, 0, prs.slide_width, prs.slide_height
|
|
)
|
|
background.fill.solid()
|
|
background.fill.fore_color.rgb = PptxRGBColor(0, 102, 204)
|
|
background.line.fill.background()
|
|
|
|
# Titre principal
|
|
title_box = slide1.shapes.add_textbox(
|
|
PptxInches(1), PptxInches(2.5),
|
|
PptxInches(8), PptxInches(2)
|
|
)
|
|
title_frame = title_box.text_frame
|
|
title_frame.text = "TRANSFORMATION DIGITALE 2025"
|
|
title_para = title_frame.paragraphs[0]
|
|
title_para.font.size = PptxPt(54)
|
|
title_para.font.bold = True
|
|
title_para.font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
title_para.alignment = PP_ALIGN.CENTER
|
|
|
|
# Sous-titre
|
|
subtitle_box = slide1.shapes.add_textbox(
|
|
PptxInches(1), PptxInches(4.8),
|
|
PptxInches(8), PptxInches(1)
|
|
)
|
|
subtitle_frame = subtitle_box.text_frame
|
|
subtitle_frame.text = "Stratégie, Innovation et Excellence Opérationnelle"
|
|
subtitle_para = subtitle_frame.paragraphs[0]
|
|
subtitle_para.font.size = PptxPt(24)
|
|
subtitle_para.font.italic = True
|
|
subtitle_para.font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
subtitle_para.alignment = PP_ALIGN.CENTER
|
|
|
|
# SLIDE 2: AGENDA
|
|
slide2 = prs.slides.add_slide(prs.slide_layouts[1])
|
|
title2 = slide2.shapes.title
|
|
title2.text = "Agenda de la Présentation"
|
|
title2.text_frame.paragraphs[0].font.size = PptxPt(40)
|
|
title2.text_frame.paragraphs[0].font.color.rgb = PptxRGBColor(0, 102, 204)
|
|
|
|
body2 = slide2.placeholders[1]
|
|
tf2 = body2.text_frame
|
|
tf2.clear()
|
|
|
|
agenda_items = [
|
|
"Contexte et Enjeux Stratégiques",
|
|
"Analyse des Performances 2024",
|
|
"Objectifs de Transformation Digitale",
|
|
"Initiatives Clés et Roadmap",
|
|
"Budget et Ressources",
|
|
"Indicateurs de Succès et KPIs",
|
|
"Plan d'Action et Prochaines Étapes"
|
|
]
|
|
|
|
for i, item in enumerate(agenda_items):
|
|
p = tf2.add_paragraph()
|
|
p.text = item
|
|
p.level = 0
|
|
p.font.size = PptxPt(20)
|
|
p.space_before = PptxPt(8)
|
|
|
|
# Numérotation colorée
|
|
run = p.runs[0]
|
|
run.text = f"{i+1}. {item}"
|
|
if i % 2 == 0:
|
|
run.font.color.rgb = PptxRGBColor(0, 102, 204)
|
|
else:
|
|
run.font.color.rgb = PptxRGBColor(255, 102, 0)
|
|
|
|
# SLIDE 3: DONNÉES AVEC GRAPHIQUE
|
|
slide3 = prs.slides.add_slide(prs.slide_layouts[5])
|
|
title3 = slide3.shapes.title
|
|
title3.text = "Croissance et Performance Financière"
|
|
|
|
# Créer graphique pour PPT
|
|
chart_img = SAMPLE_DIR / "ppt_financial_chart.png"
|
|
fig, ax = plt.subplots(figsize=(10, 6))
|
|
|
|
years = ['2020', '2021', '2022', '2023', '2024']
|
|
revenue = [125, 145, 168, 195, 228]
|
|
profit = [15, 22, 28, 35, 48]
|
|
|
|
x = np.arange(len(years))
|
|
width = 0.35
|
|
|
|
bars1 = ax.bar(x - width/2, revenue, width, label='Revenus (M€)', color='#0066CC')
|
|
bars2 = ax.bar(x + width/2, profit, width, label='Bénéfices (M€)', color='#FF6600')
|
|
|
|
ax.set_xlabel('Années', fontsize=12, fontweight='bold')
|
|
ax.set_ylabel('Montants (M€)', fontsize=12, fontweight='bold')
|
|
ax.set_title('Évolution Financière 2020-2024', fontsize=16, fontweight='bold')
|
|
ax.set_xticks(x)
|
|
ax.set_xticklabels(years)
|
|
ax.legend(fontsize=11)
|
|
ax.grid(True, alpha=0.3)
|
|
|
|
# Ajouter valeurs sur les barres
|
|
for bars in [bars1, bars2]:
|
|
for bar in bars:
|
|
height = bar.get_height()
|
|
ax.text(bar.get_x() + bar.get_width()/2., height,
|
|
f'{int(height)}',
|
|
ha='center', va='bottom', fontsize=10, fontweight='bold')
|
|
|
|
plt.tight_layout()
|
|
plt.savefig(chart_img, dpi=150, bbox_inches='tight', facecolor='white')
|
|
plt.close()
|
|
|
|
slide3.shapes.add_picture(
|
|
str(chart_img),
|
|
PptxInches(1.5), PptxInches(2),
|
|
width=PptxInches(7)
|
|
)
|
|
|
|
# SLIDE 4: TABLEAU COMPLEXE
|
|
slide4 = prs.slides.add_slide(prs.slide_layouts[5])
|
|
title4 = slide4.shapes.title
|
|
title4.text = "Répartition Budgétaire par Département"
|
|
|
|
# Tableau
|
|
rows, cols = 8, 5
|
|
table = slide4.shapes.add_table(
|
|
rows, cols,
|
|
PptxInches(0.8), PptxInches(2),
|
|
PptxInches(8.4), PptxInches(4)
|
|
).table
|
|
|
|
# En-têtes
|
|
headers = ['Département', 'Budget 2024 (M€)', 'Budget 2025 (M€)', 'Variation', 'Priorité']
|
|
for col, header in enumerate(headers):
|
|
cell = table.cell(0, col)
|
|
cell.text = header
|
|
cell.fill.solid()
|
|
cell.fill.fore_color.rgb = PptxRGBColor(0, 102, 204)
|
|
for paragraph in cell.text_frame.paragraphs:
|
|
for run in paragraph.runs:
|
|
run.font.size = PptxPt(14)
|
|
run.font.bold = True
|
|
run.font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER
|
|
|
|
# Données
|
|
dept_data = [
|
|
('Recherche & Développement', '45.2', '58.5', '+29.4%', 'Élevée'),
|
|
('Ventes & Marketing', '38.7', '42.3', '+9.3%', 'Élevée'),
|
|
('Opérations', '52.3', '55.1', '+5.4%', 'Moyenne'),
|
|
('IT & Infrastructure', '28.5', '35.2', '+23.5%', 'Élevée'),
|
|
('Ressources Humaines', '15.8', '17.2', '+8.9%', 'Moyenne'),
|
|
('Administration', '12.3', '13.1', '+6.5%', 'Faible'),
|
|
('TOTAL', '192.8', '221.4', '+14.8%', '-')
|
|
]
|
|
|
|
for row_idx, row_data in enumerate(dept_data, 1):
|
|
for col_idx, value in enumerate(row_data):
|
|
cell = table.cell(row_idx, col_idx)
|
|
cell.text = value
|
|
|
|
# Formatage spécial pour la ligne total
|
|
if row_idx == 7:
|
|
cell.fill.solid()
|
|
cell.fill.fore_color.rgb = PptxRGBColor(255, 215, 0)
|
|
for paragraph in cell.text_frame.paragraphs:
|
|
for run in paragraph.runs:
|
|
run.font.bold = True
|
|
run.font.size = PptxPt(13)
|
|
else:
|
|
# Alternance de couleurs
|
|
if row_idx % 2 == 0:
|
|
cell.fill.solid()
|
|
cell.fill.fore_color.rgb = PptxRGBColor(240, 248, 255)
|
|
|
|
for paragraph in cell.text_frame.paragraphs:
|
|
for run in paragraph.runs:
|
|
run.font.size = PptxPt(12)
|
|
|
|
# Alignement
|
|
cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER if col_idx > 0 else PP_ALIGN.LEFT
|
|
|
|
# SLIDE 5: INITIATIVES CLÉS AVEC FORMES
|
|
slide5 = prs.slides.add_slide(prs.slide_layouts[5])
|
|
title5 = slide5.shapes.title
|
|
title5.text = "Initiatives Stratégiques 2025"
|
|
|
|
initiatives = [
|
|
("Innovation IA", "Intégration IA dans tous les produits", PptxRGBColor(46, 125, 50)),
|
|
("Cloud First", "Migration complète vers le cloud", PptxRGBColor(33, 150, 243)),
|
|
("Customer 360", "Vue unifiée du parcours client", PptxRGBColor(255, 152, 0)),
|
|
("Green IT", "Neutralité carbone datacenter", PptxRGBColor(76, 175, 80))
|
|
]
|
|
|
|
y_position = 2.2
|
|
for i, (title_text, desc, color) in enumerate(initiatives):
|
|
# Rectangle coloré
|
|
shape = slide5.shapes.add_shape(
|
|
MSO_SHAPE.ROUNDED_RECTANGLE,
|
|
PptxInches(1), PptxInches(y_position),
|
|
PptxInches(8), PptxInches(1)
|
|
)
|
|
shape.fill.solid()
|
|
shape.fill.fore_color.rgb = color
|
|
shape.line.color.rgb = color
|
|
shape.shadow.inherit = False
|
|
|
|
# Texte dans la forme
|
|
text_frame = shape.text_frame
|
|
text_frame.clear()
|
|
|
|
p1 = text_frame.paragraphs[0]
|
|
p1.text = title_text
|
|
p1.font.size = PptxPt(22)
|
|
p1.font.bold = True
|
|
p1.font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
p1.alignment = PP_ALIGN.LEFT
|
|
|
|
p2 = text_frame.add_paragraph()
|
|
p2.text = desc
|
|
p2.font.size = PptxPt(16)
|
|
p2.font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
p2.alignment = PP_ALIGN.LEFT
|
|
p2.space_before = PptxPt(5)
|
|
|
|
text_frame.vertical_anchor = MSO_ANCHOR.MIDDLE
|
|
text_frame.margin_left = PptxInches(0.3)
|
|
|
|
y_position += 1.2
|
|
|
|
# SLIDE 6: TIMELINE
|
|
slide6 = prs.slides.add_slide(prs.slide_layouts[5])
|
|
title6 = slide6.shapes.title
|
|
title6.text = "Roadmap de Déploiement"
|
|
|
|
# Timeline horizontale
|
|
timeline_data = [
|
|
("Q1", "Planification", PptxRGBColor(76, 175, 80)),
|
|
("Q2", "Développement", PptxRGBColor(33, 150, 243)),
|
|
("Q3", "Tests & Pilotes", PptxRGBColor(255, 152, 0)),
|
|
("Q4", "Déploiement", PptxRGBColor(156, 39, 176))
|
|
]
|
|
|
|
x_start = 1
|
|
y_pos = 3
|
|
width = 1.8
|
|
|
|
for quarter, phase, color in timeline_data:
|
|
# Cercle pour le trimestre
|
|
circle = slide6.shapes.add_shape(
|
|
MSO_SHAPE.OVAL,
|
|
PptxInches(x_start), PptxInches(y_pos),
|
|
PptxInches(0.8), PptxInches(0.8)
|
|
)
|
|
circle.fill.solid()
|
|
circle.fill.fore_color.rgb = color
|
|
circle.line.color.rgb = color
|
|
|
|
# Texte du trimestre
|
|
tf = circle.text_frame
|
|
tf.text = quarter
|
|
tf.paragraphs[0].font.size = PptxPt(18)
|
|
tf.paragraphs[0].font.bold = True
|
|
tf.paragraphs[0].font.color.rgb = PptxRGBColor(255, 255, 255)
|
|
tf.paragraphs[0].alignment = PP_ALIGN.CENTER
|
|
tf.vertical_anchor = MSO_ANCHOR.MIDDLE
|
|
|
|
# Description de la phase
|
|
text_box = slide6.shapes.add_textbox(
|
|
PptxInches(x_start - 0.3), PptxInches(y_pos + 1.2),
|
|
PptxInches(1.4), PptxInches(0.6)
|
|
)
|
|
tf2 = text_box.text_frame
|
|
tf2.text = phase
|
|
tf2.paragraphs[0].font.size = PptxPt(14)
|
|
tf2.paragraphs[0].font.bold = True
|
|
tf2.paragraphs[0].font.color.rgb = color
|
|
tf2.paragraphs[0].alignment = PP_ALIGN.CENTER
|
|
|
|
# Ligne de connexion (sauf pour le dernier)
|
|
if x_start < 7:
|
|
line = slide6.shapes.add_connector(
|
|
1, # Straight connector
|
|
PptxInches(x_start + 0.8), PptxInches(y_pos + 0.4),
|
|
PptxInches(x_start + width), PptxInches(y_pos + 0.4)
|
|
)
|
|
line.line.color.rgb = PptxRGBColor(100, 100, 100)
|
|
line.line.width = PptxPt(3)
|
|
|
|
x_start += width
|
|
|
|
# SLIDE 7: CONCLUSION
|
|
slide7 = prs.slides.add_slide(prs.slide_layouts[1])
|
|
title7 = slide7.shapes.title
|
|
title7.text = "Prochaines Étapes et Engagement"
|
|
|
|
body7 = slide7.placeholders[1]
|
|
tf7 = body7.text_frame
|
|
tf7.clear()
|
|
|
|
next_steps = [
|
|
"Validation du comité exécutif - Janvier 2025",
|
|
"Kick-off des programmes prioritaires - Février 2025",
|
|
"Revues mensuelles de progression avec les sponsors",
|
|
"Communication régulière à toutes les parties prenantes",
|
|
"Ajustements agiles basés sur les retours du terrain"
|
|
]
|
|
|
|
for step in next_steps:
|
|
p = tf7.add_paragraph()
|
|
p.text = step
|
|
p.level = 0
|
|
p.font.size = PptxPt(20)
|
|
p.space_before = PptxPt(10)
|
|
p.font.color.rgb = PptxRGBColor(0, 102, 204)
|
|
|
|
# Ajouter une image de conclusion
|
|
conclusion_img = SAMPLE_DIR / "ppt_conclusion_image.png"
|
|
img = Image.new('RGB', (800, 300), color=(255, 255, 255))
|
|
draw = ImageDraw.Draw(img)
|
|
|
|
# Dessiner un graphique de succès stylisé
|
|
draw.rectangle([50, 50, 750, 250], outline=(0, 102, 204), width=3)
|
|
try:
|
|
font = ImageFont.truetype("arial.ttf", 50)
|
|
except:
|
|
font = ImageFont.load_default()
|
|
draw.text((400, 150), "SUCCÈS 2025", fill=(0, 102, 204), font=font, anchor="mm")
|
|
img.save(conclusion_img)
|
|
|
|
slide7.shapes.add_picture(
|
|
str(conclusion_img),
|
|
PptxInches(2.5), PptxInches(5),
|
|
width=PptxInches(5)
|
|
)
|
|
|
|
# Ajouter notes de présentation
|
|
notes_slide = slide1.notes_slide
|
|
notes_slide.notes_text_frame.text = "Bienvenue à tous. Cette présentation couvre notre stratégie de transformation digitale pour 2025. Nous allons explorer nos objectifs ambitieux et le plan d'action pour les atteindre."
|
|
|
|
# Sauvegarder PowerPoint
|
|
ppt_file = SAMPLE_DIR / "super_complex.pptx"
|
|
prs.save(ppt_file)
|
|
print(f"✅ PowerPoint créé: {ppt_file}")
|
|
print(f" - 7 diapositives professionnelles")
|
|
print(f" - Slide de titre avec design custom")
|
|
print(f" - Agenda structuré avec numérotation")
|
|
print(f" - Tableau complexe 8x5 avec formatage")
|
|
print(f" - Graphiques intégrés (barres avec valeurs)")
|
|
print(f" - Timeline visuelle avec formes connectées")
|
|
print(f" - 4 initiatives avec rectangles colorés")
|
|
print(f" - Images et formes multiples")
|
|
print(f" - Notes de présentation\n")
|
|
|
|
print("=" * 70)
|
|
print("🎉 TOUS LES FICHIERS COMPLEXES ONT ÉTÉ CRÉÉS AVEC SUCCÈS!")
|
|
print("=" * 70)
|
|
print(f"\n📁 Fichiers disponibles dans: {SAMPLE_DIR.absolute()}")
|
|
print("\nVous pouvez maintenant:")
|
|
print("1. Ouvrir les fichiers pour vérifier la complexité")
|
|
print("2. Les traduire via l'API")
|
|
print("3. Vérifier que le formatage est préservé")
|
|
print("\n✨ Formatage inclus:")
|
|
print(" Excel: Formules, cellules fusionnées, graphiques, formatage conditionnel")
|
|
print(" Word: Images, tableaux, styles, couleurs, pieds de page")
|
|
print(" PowerPoint: Formes, graphiques, timeline, tableaux, animations visuelles")
|