Skip to content

Commit fffbb8c

Browse files
committed
feature: support more than one handler for a file format. e.g. openpyxl and xlrd both reads xlsx. if both were installed, the developer has the way to choose one of them
1 parent 5ad7eb0 commit fffbb8c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pyexcel_xls/xls.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,26 +245,37 @@ def close(self):
245245
self.work_book.save(self.file_alike_object)
246246

247247

248-
_xls_registry = {
248+
_xls_reader_registry = {
249249
"file_type": "xls",
250250
"reader": XLSBook,
251+
"stream_type": "binary",
252+
"mime_type": "application/vnd.ms-excel",
253+
"library": "xlrd"
254+
}
255+
256+
_xls_writer_registry = {
257+
"file_type": "xls",
251258
"writer": XLSWriter,
252259
"stream_type": "binary",
253-
"mime_type": "application/vnd.ms-excel"
260+
"mime_type": "application/vnd.ms-excel",
261+
"library": "xlwt-future"
254262
}
255263

256264
_xlsm_registry = {
257265
"file_type": "xlsm",
258266
"reader": XLSBook,
259267
"stream_type": "binary",
260-
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
268+
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
269+
"library": "xlrd"
261270
}
262271

263272
_xlsx_registry = {
264273
"file_type": "xlsx",
265274
"reader": XLSBook,
266275
"stream_type": "binary",
267-
"mime_type": "application/vnd.ms-excel.sheet.macroenabled.12"
276+
"mime_type": "application/vnd.ms-excel.sheet.macroenabled.12",
277+
"library": "xlrd"
268278
}
269279

270-
exports = (_xls_registry, _xlsm_registry, _xlsx_registry)
280+
exports = (_xls_reader_registry, _xls_writer_registry,
281+
_xlsm_registry, _xlsx_registry)

0 commit comments

Comments
 (0)