@@ -714,11 +714,14 @@ class _XlsxWriter(ExcelWriter):
714
714
engine = 'xlsxwriter'
715
715
supported_extensions = ('.xlsx' ,)
716
716
717
- def __init__ (self , path , engine = None , ** engine_kwargs ):
717
+ def __init__ (self , path , engine = None ,
718
+ date_format = None , datetime_format = None , ** engine_kwargs ):
718
719
# Use the xlsxwriter module as the Excel writer.
719
720
import xlsxwriter
720
721
721
- super (_XlsxWriter , self ).__init__ (path , engine = engine , ** engine_kwargs )
722
+ super (_XlsxWriter , self ).__init__ (path , engine = engine ,
723
+ date_format = date_format , datetime_format = datetime_format ,
724
+ ** engine_kwargs )
722
725
723
726
self .book = xlsxwriter .Workbook (path , ** engine_kwargs )
724
727
@@ -777,12 +780,16 @@ def _convert_to_style(self, style_dict, num_format_str=None):
777
780
style_dict: style dictionary to convert
778
781
num_format_str: optional number format string
779
782
"""
780
- if style_dict is None :
781
- return None
782
783
783
784
# Create a XlsxWriter format object.
784
785
xl_format = self .book .add_format ()
786
+
787
+ if num_format_str is not None :
788
+ xl_format .set_num_format (num_format_str )
785
789
790
+ if style_dict is None :
791
+ return xl_format
792
+
786
793
# Map the cell font to XlsxWriter font properties.
787
794
if style_dict .get ('font' ):
788
795
font = style_dict ['font' ]
@@ -803,9 +810,6 @@ def _convert_to_style(self, style_dict, num_format_str=None):
803
810
if style_dict .get ('borders' ):
804
811
xl_format .set_border ()
805
812
806
- if num_format_str is not None :
807
- xl_format .set_num_format (num_format_str )
808
-
809
813
return xl_format
810
814
811
815
register_writer (_XlsxWriter )
0 commit comments