I want to write / change a value to a single cell of an existing xlsm file (let's call it filename.xlsm), maintaining all macros and properties of the original xlsm file.
filename.xlsm has several sheets. I wish to write the value 4 in cell E3 of sheet 'Sup'.
I get the error "xml.etree.ElementTree.ParseError: mismatched tag: line 42, column 8"
The PYTHON code
import pandas as pd
import numpy as np
import openpyxl
InputExcelfile = openpyxl.load_workbook('filename.xlsm', keep_vba=True)
sup_sheet = InputExcelfile['Sup']
sup_sheet['E3'] = 4
InputExcelfile.save('filename.xlsm')
I have tried deleting several sheets to see if the error disappears, but this only happens with this sheet.
After running the program and getting the error, I try accessing the Excel and get the error:
Excel error message
Help would be very much appreciated.
Many thanks.
question from:
https://stackoverflow.com/questions/66054950/error-writing-to-an-existing-xlsm-file-using-openpyxl-xml-etree-elementtree-p 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…