@@ -417,7 +417,8 @@ def _convert_to_protection(cls, protection_dict):
417
417
return Protection (** protection_dict )
418
418
419
419
def write_cells (
420
- self , cells , sheet_name = None , startrow = 0 , startcol = 0 , freeze_panes = None
420
+ self , cells , sheet_name = None , startrow = 0 , startcol = 0 ,
421
+ freeze_panes = None , autofilter = False
421
422
):
422
423
# Write the frame cells using openpyxl.
423
424
sheet_name = self ._get_sheet_name (sheet_name )
@@ -454,6 +455,9 @@ def write_cells(
454
455
row = freeze_panes [0 ] + 1 , column = freeze_panes [1 ] + 1
455
456
)
456
457
458
+ max_row = 0
459
+ max_col = 0
460
+
457
461
for cell in cells :
458
462
xcell = wks .cell (
459
463
row = startrow + cell .row + 1 , column = startcol + cell .col + 1
@@ -501,6 +505,15 @@ def write_cells(
501
505
for k , v in style_kwargs .items ():
502
506
setattr (xcell , k , v )
503
507
508
+ if startrow + cell .row > max_row :
509
+ max_row = startrow + cell .row
510
+ if startcol + cell .col > max_col :
511
+ max_col = startcol + cell .col
512
+
513
+ if autofilter :
514
+ from openpyxl .utils import get_column_letter
515
+ wks .auto_filter .ref = "A1:" + get_column_letter (max_col + 1 ) + str (max_row )
516
+
504
517
505
518
class OpenpyxlReader (BaseExcelReader ):
506
519
def __init__ (
0 commit comments