Losing images after loading and saving a workbook

Issue #870 closed
Jacek Witkowski
created an issue

After loading a workbook and then saving it without modification I lose all the images in it. I attached the example file.

Code to reproduce the issue:

from openpyxl import load_workbook

input_file = "input.xlsx"
output_file = "output.xlsx"

wb = load_workbook(input_file)
wb.save(output_file)

Comments (7)

  1. Jacek Witkowski reporter

    Is this what you mean?

    openpyxl does currently not read all possible items in an Excel file so images and charts will be lost from existing files if they are opened and saved with the same name

    Please see that I'm saving with a different filename.

    Thanks in advance. I really appreciate what you're doing, guys!

  2. CharlieC

    The filename doesn't matter: images aren't preserved. There is also no such thing as "saving without modification": the original file is overwritten.

  3. Jacek Witkowski reporter

    What I meant by "without modification" was without modifying the workbook. If you read my code, you could see that the output file is different than the input file. Secondly, of course it's your project and you may do whatever you want, but in my opinion if a bug is known and is documented it still doesn't mean that it's resolved. You could change its type from "Bug" to "Feature" instead of closing it. Anyway, thanks for providing the best Excel utility for Python there is.

  4. CharlieC

    I know what "without modification" means to a user but the file format is different. If you mean: support images when reading files then this is on the todo list.

  5. Log in to comment