Open macifTest opened 2 years ago
Thanks for your reply. I tried your suggestion, but it doesn't work. The MIME type is still not good. This shows me: application/zip bellow the code I used : with open(file_origin, mode="rb+") as handle: book = openpyxl.load_workbook(handle) handle.seek(0) with pd.ExcelWriter( handle, if_sheet_exists="overlay", engine="openpyxl", mode="a" ) as xl_writer: xl_writer.book = book # still uses the same handle! xl_writer.sheets = dict((ws.title, ws) for ws in book.worksheets) chunk = pd.DataFrame([date, date, date, date], index=[2,3,4,5]) chunk.to_excel(xl_writer, merge_cells=False, index=False, startrow=2, startcol=5, header=False, verbose=True, sheet_name="PCA pour intégration")
Thanks
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I have an issue with the use of Pandas + ExcelWriter + load_workbook. My need is to be able to modify data from an existing excel file (without deleting the rest). It works partly, but when I check the MIME Type of the produced file and the MIME TYPE of the original one, it is different. The application under test use the same MIME TYPE verification as the website https://www.htmlstrip.com/mime-file-type-checker
Original : application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Modify : application/octet-stream
Expected Behavior
The code bellow :
data_filtered = pd.DataFrame( [date, date, date, date], index=[2,3,4,5] )
Installed Versions