|
5 | 5 |
|
6 | 6 | from pandas.core.dtypes.common import is_integer, is_list_like |
7 | 7 |
|
8 | | -from pandas.core import config |
9 | | - |
10 | | -_writer_extensions = ["xlsx", "xls", "xlsm"] |
11 | | - |
12 | | - |
13 | 8 | _writers = {} |
14 | 9 |
|
15 | 10 |
|
16 | 11 | def register_writer(klass): |
17 | | - """Adds engine to the excel writer registry. You must use this method to |
18 | | - integrate with ``to_excel``. Also adds config options for any new |
19 | | - ``supported_extensions`` defined on the writer.""" |
| 12 | + """ |
| 13 | + Add engine to the excel writer registry.io.excel. |
| 14 | +
|
| 15 | + You must use this method to integrate with ``to_excel``. |
| 16 | +
|
| 17 | + Parameters |
| 18 | + ---------- |
| 19 | + klass : ExcelWriter |
| 20 | + """ |
20 | 21 | if not callable(klass): |
21 | 22 | raise ValueError("Can only register callables as engines") |
22 | 23 | engine_name = klass.engine |
23 | 24 | _writers[engine_name] = klass |
24 | | - for ext in klass.supported_extensions: |
25 | | - if ext.startswith('.'): |
26 | | - ext = ext[1:] |
27 | | - if ext not in _writer_extensions: |
28 | | - config.register_option("io.excel.{ext}.writer".format(ext=ext), |
29 | | - engine_name, validator=str) |
30 | | - _writer_extensions.append(ext) |
31 | 25 |
|
32 | 26 |
|
33 | 27 | def _get_default_writer(ext): |
| 28 | + """ |
| 29 | + Return the default writer for the given extension. |
| 30 | +
|
| 31 | + Parameters |
| 32 | + ---------- |
| 33 | + ext : str |
| 34 | + The excel file extension for which to get the default engine. |
| 35 | +
|
| 36 | + Returns |
| 37 | + ------- |
| 38 | + str |
| 39 | + The default engine for the extension. |
| 40 | + """ |
34 | 41 | _default_writers = {'xlsx': 'openpyxl', 'xlsm': 'openpyxl', 'xls': 'xlwt'} |
35 | 42 | try: |
36 | 43 | import xlsxwriter # noqa |
@@ -230,8 +237,6 @@ def _fill_mi_header(row, control_row): |
230 | 237 |
|
231 | 238 | return _maybe_convert_to_string(row), control_row |
232 | 239 |
|
233 | | -# fill blank if index_col not None |
234 | | - |
235 | 240 |
|
236 | 241 | def _pop_header_name(row, index_col): |
237 | 242 | """ |
|
0 commit comments