From fffbb8cfb3bcad5e2b1a68ae6f3432e20237d626 Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 6 May 2016 18:15:50 +0100 Subject: [PATCH] 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 --- pyexcel_xls/xls.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pyexcel_xls/xls.py b/pyexcel_xls/xls.py index 21c9fd2..ffe52e0 100644 --- a/pyexcel_xls/xls.py +++ b/pyexcel_xls/xls.py @@ -245,26 +245,37 @@ class XLSWriter(BookWriter): self.work_book.save(self.file_alike_object) -_xls_registry = { +_xls_reader_registry = { "file_type": "xls", "reader": XLSBook, + "stream_type": "binary", + "mime_type": "application/vnd.ms-excel", + "library": "xlrd" +} + +_xls_writer_registry = { + "file_type": "xls", "writer": XLSWriter, "stream_type": "binary", - "mime_type": "application/vnd.ms-excel" + "mime_type": "application/vnd.ms-excel", + "library": "xlwt-future" } _xlsm_registry = { "file_type": "xlsm", "reader": XLSBook, "stream_type": "binary", - "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "library": "xlrd" } _xlsx_registry = { "file_type": "xlsx", "reader": XLSBook, "stream_type": "binary", - "mime_type": "application/vnd.ms-excel.sheet.macroenabled.12" + "mime_type": "application/vnd.ms-excel.sheet.macroenabled.12", + "library": "xlrd" } -exports = (_xls_registry, _xlsm_registry, _xlsx_registry) +exports = (_xls_reader_registry, _xls_writer_registry, + _xlsm_registry, _xlsx_registry)