Skip to content

Commit eb1788b

Browse files
Fix - the root of macrosheet can be worksheet element #102
1 parent 87fab21 commit eb1788b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

XLMMacroDeobfuscator/xlsm_wrapper.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,11 @@ def get_shared_strings(self):
265265

266266
def load_macro_cells(self, macrosheet, macrosheet_obj):
267267
strings = self.get_shared_strings()
268-
if not hasattr(macrosheet_obj.xm_macrosheet.sheetData, 'row'):
268+
269+
sheet = macrosheet_obj.xm_macrosheet if hasattr(macrosheet_obj, 'xm_macrosheet') else macrosheet_obj.worksheet
270+
if not hasattr(sheet.sheetData, 'row'):
269271
return
270-
for row in macrosheet_obj.xm_macrosheet.sheetData.row:
272+
for row in sheet.sheetData.row:
271273
row_attribs = {}
272274
for attr in row._attributes:
273275
if attr == 'ht':
@@ -381,8 +383,10 @@ def get_macrosheets(self):
381383
# if the actual file exist
382384
if macrosheet['sheet_xml']:
383385
self.load_macro_cells(macrosheet['sheet'], macrosheet['sheet_xml'])
384-
if hasattr(macrosheet['sheet_xml'].xm_macrosheet, 'sheetFormatPr'):
385-
macrosheet['sheet'].default_height = macrosheet['sheet_xml'].xm_macrosheet.sheetFormatPr.get_attribute(
386+
sheet = macrosheet['sheet_xml'].xm_macrosheet if hasattr(macrosheet['sheet_xml'],
387+
'xm_macrosheet') else macrosheet['sheet_xml'].worksheet
388+
if hasattr(sheet, 'sheetFormatPr'):
389+
macrosheet['sheet'].default_height = sheet.sheetFormatPr.get_attribute(
386390
'defaultRowHeight')
387391

388392
self._macrosheets[macrosheet['sheet'].name] = macrosheet['sheet']

0 commit comments

Comments
 (0)