|
14 | 14 | from pyexcel_io._compact import OrderedDict, irange
|
15 | 15 |
|
16 | 16 |
|
| 17 | +class FastSheet(SheetReader): |
| 18 | + """ |
| 19 | + Iterate through rows |
| 20 | + """ |
| 21 | + @property |
| 22 | + def name(self): |
| 23 | + """sheet name""" |
| 24 | + return self._native_sheet.title |
| 25 | + |
| 26 | + def row_iterator(self): |
| 27 | + """ |
| 28 | + openpyxl row iterator |
| 29 | +
|
| 30 | + http://openpyxl.readthedocs.io/en/default/optimized.html |
| 31 | + """ |
| 32 | + for row in self._native_sheet.rows: |
| 33 | + yield row |
| 34 | + |
| 35 | + def column_iterator(self, row): |
| 36 | + """ |
| 37 | + a generator for the values in a row |
| 38 | + """ |
| 39 | + for cell in row: |
| 40 | + yield cell.value |
| 41 | + |
| 42 | + |
17 | 43 | class MergedCell(object):
|
18 | 44 | def __init__(self, cell_ranges_str):
|
19 | 45 | topleft, bottomright = cell_ranges_str.split(':')
|
@@ -41,33 +67,7 @@ def convert_coordinate(cell_coordinate_with_letter):
|
41 | 67 | return row, col
|
42 | 68 |
|
43 | 69 |
|
44 |
| -class XLSXSheet(SheetReader): |
45 |
| - """ |
46 |
| - Iterate through rows |
47 |
| - """ |
48 |
| - @property |
49 |
| - def name(self): |
50 |
| - """sheet name""" |
51 |
| - return self._native_sheet.title |
52 |
| - |
53 |
| - def row_iterator(self): |
54 |
| - """ |
55 |
| - openpyxl row iterator |
56 |
| -
|
57 |
| - http://openpyxl.readthedocs.io/en/default/optimized.html |
58 |
| - """ |
59 |
| - for row in self._native_sheet.rows: |
60 |
| - yield row |
61 |
| - |
62 |
| - def column_iterator(self, row): |
63 |
| - """ |
64 |
| - a generator for the values in a row |
65 |
| - """ |
66 |
| - for cell in row: |
67 |
| - yield cell.value |
68 |
| - |
69 |
| - |
70 |
| -class SlowSheet(XLSXSheet): |
| 70 | +class SlowSheet(FastSheet): |
71 | 71 | """
|
72 | 72 | This sheet will be slower because it does not use readonly sheet
|
73 | 73 | """
|
@@ -184,7 +184,7 @@ def read_sheet(self, native_sheet):
|
184 | 184 | if self.skip_hidden_row_and_column or self.detect_merged_cells:
|
185 | 185 | sheet = SlowSheet(native_sheet, **self._keywords)
|
186 | 186 | else:
|
187 |
| - sheet = XLSXSheet(native_sheet, **self._keywords) |
| 187 | + sheet = FastSheet(native_sheet, **self._keywords) |
188 | 188 | return {sheet.name: sheet.to_array()}
|
189 | 189 |
|
190 | 190 | def close(self):
|
|
0 commit comments