Skip to content

Commit 7e359b2

Browse files
authored
Update OpenPyxlLibrary.py
Open Excel should allow now to keep VBA scripts inside XLSM files.
1 parent 2db3b34 commit 7e359b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

OpenPyxlLibrary/OpenPyxlLibrary.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/usr/bin/env python
2+
'''
3+
Description: My fork of OpenPyxlLib to support Python3 (should still work with Python 2) and is supports also XLSM files (with VBA scripts)
4+
5+
'''
26

37

48

@@ -38,7 +42,7 @@ def open_excel(self, file):
3842
"""
3943
if os.path.exists(file):
4044
self.filename = file
41-
self.wb = openpyxl.load_workbook(self.filename)
45+
self.wb = openpyxl.load_workbook(self.filename, read_only=False, keep_vba=True)
4246
else:
4347
print('11111')
4448
self.wb = openpyxl.Workbook()
@@ -163,4 +167,4 @@ def append_new_data(self,sheetname,data):
163167
opxl=OpenPyxlLibrary()
164168
opxl.open_excel('test1.xlsx')
165169
opxl.get_sheet_names('test1.xlsx')
166-
opxl.save_excel('test1.xlsx')
170+
opxl.save_excel('test1.xlsx')

0 commit comments

Comments
 (0)