I want to transfer the data from one xlsx file to another xlsx file, so I write this:
from openpyxl import load_workbook
wb_source = load_workbook('test.xlsx')
wb_target = load_workbook('template.xlsx',keep_vba=True)
but seems second load doesn't work:
TypeError Traceback (most recent call last)
<ipython-input-1-f9200c00961e> in <module>()
2
3 wb_source = load_workbook('test.xlsx') #Get the current Active Sheet
----> 4 wb_target = load_workbook('template.xlsx',keep_vba=True)
5 #based on sheet name
6 #ws_source = wb_source.get_sheet_by_name("raw-74126")
C:\Anaconda3\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, use_iterators, keep_vba, guess_types, data_only)
190 if strings_path.startswith("/"):
191 strings_path = strings_path[1:]
--> 192 shared_strings = read_string_table(archive.read(strings_path))
193 else:
194 shared_strings = []
C:\Anaconda3\lib\site-packages\openpyxl\reader\strings.py in read_string_table(xml_source)
19 if node.tag == '{%s}si' % SHEET_MAIN_NS:
20
---> 21 text = Text.from_tree(node).content
22 text = text.replace('x005F_', '')
23 strings.append(text)
C:\Anaconda3\lib\site-packages\openpyxl\cell\text.py in content(self)
183 for block in self.formatted:
184 snippets.append(block.t)
--> 185 return "".join(snippets)
TypeError: sequence item 2: expected str instance, NoneType found
The target one is I save as from a xlsm file, could you guys help me to see what happens?
有必要将模块openpyxl更新到2.4.2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.