@@ -587,6 +587,13 @@ class ExcelWriter(metaclass=abc.ABCMeta):
587587 Engine to use for writing. If None, defaults to
588588 ``io.excel.<extension>.writer``. NOTE: can only be passed as a keyword
589589 argument.
590+
591+ .. deprecated:: 1.2.0
592+
593+ As the `xlwt <https://pypi.org/project/xlwt/>`__ package is no longer
594+ maintained, the ``xlwt`` engine will be removed in a future
595+ version of pandas.
596+
590597 date_format : str, default None
591598 Format string for dates written into Excel files (e.g. 'YYYY-MM-DD').
592599 datetime_format : str, default None
@@ -691,11 +698,31 @@ def __new__(cls, path, engine=None, **kwargs):
691698 ext = "xlsx"
692699
693700 try :
694- engine = config .get_option (f"io.excel.{ ext } .writer" )
701+ engine = config .get_option (f"io.excel.{ ext } .writer" , silent = True )
695702 if engine == "auto" :
696703 engine = get_default_writer (ext )
697704 except KeyError as err :
698705 raise ValueError (f"No engine for filetype: '{ ext } '" ) from err
706+
707+ if engine == "xlwt" :
708+ xls_config_engine = config .get_option (
709+ "io.excel.xls.writer" , silent = True
710+ )
711+ # Don't warn a 2nd time if user has changed the default engine for xls
712+ if xls_config_engine != "xlwt" :
713+ warnings .warn (
714+ "As the xlwt package is no longer maintained, the xlwt "
715+ "engine will be removed in a future version of pandas. "
716+ "This is the only engine in pandas that supports writing "
717+ "in the xls format. Install openpyxl and write to an xlsx "
718+ "file instead. You can set the option io.excel.xls.writer "
719+ "to 'xlwt' to silence this warning. While this option is "
720+ "deprecated and will also raise a warning, it can "
721+ "be globally set and the warning suppressed." ,
722+ FutureWarning ,
723+ stacklevel = 4 ,
724+ )
725+
699726 cls = get_writer (engine )
700727
701728 return object .__new__ (cls )
0 commit comments