2
2
from io import BytesIO
3
3
4
4
import pyexcel_io .service as service
5
- from pyexcel_io .plugin_api .abstract_reader import IReader
6
- from pyexcel_io .plugin_api .abstract_sheet import ISheet
7
-
5
+ from pyexcel_io .plugin_api import IReader , ISheet , NamedContent
8
6
from pyexcel_xlsxr .messy_xlsx import XLSXBookSet
9
7
10
8
@@ -15,20 +13,14 @@ def __init__(
15
13
auto_detect_int = True ,
16
14
auto_detect_float = True ,
17
15
auto_detect_datetime = True ,
18
- ** keywords
19
16
):
20
- self ._native_sheet = sheet
17
+ self .xlsx_sheet = sheet
21
18
self .__auto_detect_int = auto_detect_int
22
19
self .__auto_detect_float = auto_detect_float
23
20
self .__auto_detect_datetime = auto_detect_datetime
24
- self ._keywords = keywords
25
-
26
- @property
27
- def name (self ):
28
- return self ._native_sheet .name
29
21
30
22
def row_iterator (self ):
31
- return self ._native_sheet .raw ()
23
+ return self .xlsx_sheet .raw ()
32
24
33
25
def column_iterator (self , row ):
34
26
for cell in row :
@@ -57,30 +49,24 @@ def __convert_cell(self, cell):
57
49
58
50
class XLSXBook (IReader ):
59
51
def __init__ (self , file_alike_object , _ , ** keywords ):
60
- self ._native_book = XLSXBookSet (file_alike_object )
52
+ self .xlsx_book = XLSXBookSet (file_alike_object )
61
53
self ._keywords = keywords
62
- tables = self ._native_book .make_tables ()
54
+ tables = self .xlsx_book .make_tables ()
63
55
self .content_array = [
64
- NameObject (table .name , table ) for table in tables
56
+ NameContent (table .name , table ) for table in tables
65
57
]
66
58
67
59
def read_sheet (self , sheet_index ):
68
60
"""read a sheet at a specified index"""
69
- table = self .content_array [sheet_index ].sheet
61
+ table = self .content_array [sheet_index ].payload
70
62
sheet = XLSXSheet (table , ** self ._keywords )
71
63
return sheet
72
64
73
65
def close (self ):
74
- self ._native_book .close ()
66
+ self .xlsx_book .close ()
75
67
76
68
77
69
class XLSXBookInContent (XLSXBook ):
78
70
def __init__ (self , file_content , file_type , ** keywords ):
79
71
file_stream = BytesIO (file_content )
80
72
super ().__init__ (file_stream , file_type , ** keywords )
81
-
82
-
83
- class NameObject (object ):
84
- def __init__ (self , name , sheet ):
85
- self .name = name
86
- self .sheet = sheet
0 commit comments