@@ -161,3 +161,54 @@ def test_caption_cut(get_df):
161161 dfi .export (
162162 df , "tests/test_output/caption_cut.png" , table_conversion = "chrome" , max_rows = - 1
163163 )
164+
165+
166+ @pytest .mark .parametrize ("converter" , converters )
167+ def test_complex_styled_df (document_name , get_df , converter ):
168+ df = get_df .copy ()
169+ table_styles = [
170+ {
171+ "selector" : "thead th" , # Style pour les en-têtes de colonnes
172+ "props" : [
173+ ("background-color" , "blue" ), # Fond bleu
174+ ("color" , "white" ), # Texte en blanc
175+ ("font-weight" , "bold" ), # Texte en gras
176+ ("text-align" , "center" ), # Centrer le texte
177+ ],
178+ },
179+ {
180+ "selector" : "td" , # Style général pour toutes les cellules
181+ "props" : [("border-right" , "0.8px solid black" )],
182+ },
183+ {
184+ "selector" : "td.col0" , # Largeur spécifique pour la première colonne
185+ "props" : [("width" , "200px" )],
186+ },
187+ # Appliquer une largeur spécifique à toutes les colonnes de la 2ᵉ à la dernière
188+ {
189+ "selector" : "td:nth-child(n+2)" , # `nth-child(n+2)` cible la 2ᵉ colonne et au-delà
190+ "props" : [("width" , "70px" )],
191+ },
192+ ]
193+
194+ perf_indice_stylised = (
195+ df .style .set_properties (
196+ ** {"text-align" : "center" }
197+ ) # Centrer le contenu des colonnes
198+ .set_table_styles (table_styles , overwrite = False ) # Appliquer les propriétés CSS
199+ .bar (
200+ align = 0 ,
201+ vmin = 0 ,
202+ vmax = 5000 ,
203+ height = 50 ,
204+ width = 50 ,
205+ )
206+ .hide (axis = 0 ) # Masquer l'index
207+ )
208+
209+ image_path = f"tests/test_output/{ document_name } .png"
210+ dfi .export (
211+ perf_indice_stylised ,
212+ image_path ,
213+ table_conversion = converter ,
214+ )
0 commit comments