@@ -467,11 +467,20 @@ def write_cells(
467467 for k , v in style_kwargs .items ():
468468 setattr (xcell , k , v )
469469
470- def write_table (self , cells , sheet_name = None , startrow = 0 , startcol = 0 ,
471- freeze_panes = None , header = True ):
470+ def write_table (
471+ self ,
472+ cells ,
473+ table ,
474+ sheet_name = None ,
475+ startrow = 0 ,
476+ startcol = 0 ,
477+ freeze_panes = None ,
478+ header = True ,
479+ ):
472480 # Write the frame to an excel table using openpyxl.
473481
474482 from openpyxl .worksheet .table import Table , TableStyleInfo
483+
475484 sheet_name = self ._get_sheet_name (sheet_name )
476485
477486 if sheet_name in self .sheets :
@@ -482,8 +491,9 @@ def write_table(self, cells, sheet_name=None, startrow=0, startcol=0,
482491 self .sheets [sheet_name ] = wks
483492
484493 if _validate_freeze_panes (freeze_panes ):
485- wks .freeze_panes = wks .cell (row = freeze_panes [0 ] + 1 ,
486- column = freeze_panes [1 ] + 1 )
494+ wks .freeze_panes = wks .cell (
495+ row = freeze_panes [0 ] + 1 , column = freeze_panes [1 ] + 1
496+ )
487497
488498 header_rows = 1 if header > 0 else 0
489499
@@ -496,9 +506,7 @@ def write_table(self, cells, sheet_name=None, startrow=0, startcol=0,
496506 header_cells [cell .col ] = cell .val
497507 continue
498508 wks .cell (
499- row = startrow + cell .row + 1 ,
500- column = startcol + cell .col + 1 ,
501- value = val ,
509+ row = startrow + cell .row + 1 , column = startcol + cell .col + 1 , value = val
502510 )
503511 n_cols = max (n_cols , cell .col )
504512 n_rows = max (n_rows , cell .row )
@@ -508,25 +516,27 @@ def write_table(self, cells, sheet_name=None, startrow=0, startcol=0,
508516 if col in header_cells :
509517 val = str (header_cells [col ])
510518 else :
511- val = 'Column%d' % (col + 1 )
512- wks .cell (
513- row = startrow + 1 ,
514- column = startcol + col + 1 ,
515- value = val ,
516- )
519+ val = "Column%d" % (col + 1 )
520+ wks .cell (row = startrow + 1 , column = startcol + col + 1 , value = val )
517521
518- ref = self ._to_excel_range (startrow , startcol , startrow + n_rows ,
519- startcol + n_cols )
520- tab = Table (displayName = "Table1" , ref = ref , headerRowCount = header_rows )
522+ ref = self ._to_excel_range (
523+ startrow , startcol , startrow + n_rows , startcol + n_cols
524+ )
525+ tab = Table (displayName = table , ref = ref , headerRowCount = header_rows )
521526
522527 # Add a default style with striped rows
523528 style = TableStyleInfo (
524- name = "TableStyleMedium9" , showFirstColumn = False ,
525- showLastColumn = False , showRowStripes = True , showColumnStripes = False )
529+ name = "TableStyleMedium9" ,
530+ showFirstColumn = False ,
531+ showLastColumn = False ,
532+ showRowStripes = True ,
533+ showColumnStripes = False ,
534+ )
526535 tab .tableStyleInfo = style
527536
528537 wks .add_table (tab )
529538
539+
530540class _OpenpyxlReader (_BaseExcelReader ):
531541 def __init__ (self , filepath_or_buffer : FilePathOrBuffer ) -> None :
532542 """Reader using openpyxl engine.
0 commit comments