当表格数据为数字时会触发。在我的环境下将数字单元格转换为文本依然报错。
Traceback (most recent call last):
File "[My Path]\convert.py", line 139, in <module>
gen_docx(config['template'], df, config['dst'], config['filename'])
File "[My Path]\convert.py", line 131, in gen_docx
xml_content = xml_content.replace(replace_template, val)
TypeError: replace() argument 2 must be str, not int
可能的解决方法: convert.py 的 Line 87 进行修改,保证按 str 类型读入
由
df = pd.read_excel(xls, sheet_name=xls.sheet_names[0])
修改为
df = pd.read_excel(xls, sheet_name=xls.sheet_names[0], dtype=str)
经测试可行。
当表格数据为数字时会触发。在我的环境下将数字单元格转换为文本依然报错。
可能的解决方法:
convert.py的 Line 87 进行修改,保证按str类型读入由
修改为
经测试可行。