Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2 pyexcel_xlsx 

3 ~~~~~~~~~~~~~~~~~~~ 

4 

5 The lower level xlsx file format handler using openpyxl 

6 

7 :copyright: (c) 2015-2019 by Onni Software Ltd & its contributors 

8 :license: New BSD License 

9""" 

10from pyexcel_io.io import get_data as read_data 

11from pyexcel_io.io import isstream 

12from pyexcel_io.io import save_data as write_data 

13from pyexcel_io.plugins import IOPluginInfoChain 

14 

15__FILE_TYPE__ = "xlsx" 

16IOPluginInfoChain(__name__).add_a_reader( 

17 relative_plugin_class_path="xlsxr.XLSXBook", 

18 file_types=[__FILE_TYPE__, "xlsm"], 

19 stream_type="binary", 

20).add_a_writer( 

21 relative_plugin_class_path="xlsxw.XLSXWriter", 

22 file_types=[__FILE_TYPE__, "xlsm"], 

23 stream_type="binary", 

24) 

25 

26 

27def save_data(afile, data, file_type=None, **keywords): 

28 """standalone module function for writing module supported file type""" 

29 if isstream(afile) and file_type is None: 

30 file_type = __FILE_TYPE__ 

31 write_data(afile, data, file_type=file_type, **keywords) 

32 

33 

34def get_data(afile, file_type=None, **keywords): 

35 """standalone module function for reading module supported file type""" 

36 if isstream(afile) and file_type is None: 

37 file_type = __FILE_TYPE__ 

38 return read_data(afile, file_type=file_type, **keywords)