Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
openpyxl saving files issue
#1
Is there anybody here who knows openpyxl well?

I wanted to make a little program to insert student photos next to their names. This is the first time I have used python. I managed to make it work and successfully insert the images in the correct cells.

I only opened 1 sheet of the file and made it the active sheet. At the end of the code is:

wb.save(pathToExcel + newname)

However, when I then save the file, the photos which are already in the other sheets are all gone! Not 1 photo left in any other sheet.

This is somewhat unexpected, as I did not touch those sheets.

Can anyone explain this or tell me how to prevent this?

Edit: I just opened an excel file, opened the first sheet, which is class 4, then saved it again. All the photos are now gone! Below is from the interactive shell.

Quote:>>> sheets = wb.get_sheet_names()
>>> sheets
['课程表2017-2018冬季', '商务英语2016(4)', '商务英语2016(1)', '商务英语2016(3)', '商务英语2016(2)']
>>> ws = wb.get_sheet_by_name(sheets[1])
>>> ws
<Worksheet "商务英语2016(4)">
>>> wb.save(pathToExcel + nameOfFile)
>>>
Reply


Messages In This Thread
openpyxl saving files issue - by Pedroski55 - Sep-13-2017, 04:57 AM
RE: openpyxl saving files issue - by Pedroski55 - Sep-16-2017, 02:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  openpyxl issue - How to reset sheet.ins_row to the real last row ... ejwjohn 6 2,363 Nov-08-2023, 01:19 PM
Last Post: ejwjohn
  Trouble with saving openpyxl filename fjbianchi93 4 6,133 Apr-08-2022, 12:39 PM
Last Post: fjbianchi93
  Facing issue while saving workbook Abhisht 3 7,489 Aug-19-2020, 11:44 AM
Last Post: Larz60+
  extract zip from .msg files and saving according to date stamp of email natjo 3 4,580 Aug-13-2020, 09:35 PM
Last Post: bowlofred
  Saving Files Kristenl2784 3 2,789 Jul-13-2020, 04:36 PM
Last Post: bowlofred
  How can I speed up my openpyxl program reading Excel .xlsx files? deac33 0 4,444 May-04-2020, 08:02 PM
Last Post: deac33
  Issue with creating an array of pixel data for PNG files in Google Colab The_Sarco 1 2,531 Apr-29-2020, 12:03 AM
Last Post: bowlofred
  Downloading And Saving Zip Files To A Particular Path Folder eddywinch82 2 3,540 Jan-06-2020, 07:56 PM
Last Post: eddywinch82
  Openpyxl - while saving excel file getting error shubhamjainj 1 5,568 Apr-09-2019, 12:05 PM
Last Post: Larz60+
  Python 2.7.13 Issue Reading .txt files Properly username1145 3 3,243 Mar-24-2019, 03:08 PM
Last Post: username1145

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020