Relative Content

Tag Archive for pythonexcelopenpyxl

Openpyxl method workbook.close() not working

I am trying to simply write to a spreadsheet and save it. Later on in the code the spreadsheet is being moved with shutil.move, so the file needs to be closed when it gets to that point or else shutil is unable to delete the old file. However, calling wb.close() is not actually closing the workbook, and throwing an access error when trying to delete the file later.

How can I get one row from excel file and add it to other rows in a particular place?

I’m learning to work with openpyxl and need to get information from particular cells and rearrange them to make JSON string from it. I tried different approaches, many of them work, but when I’m dealing with large excel files I get really long scripts and want to try something shorter. I found a nice short script that works just fine, but I need to add another row to my result wich is a little difficult for me because I need this row to be in a particular place and separate from other data. I can’t undestrand how to put that row in the right place.

Copying an Excel sheet from one workbook to another in Python

Please help with Python. I can’t figure out how to implement one operation. I need to move a sheet from one Excel workbook to another. It is important that this works on a computer without Excel (an alternative program is installed that can work with xlsx files). How can I do this?

Python script won’t rename last .xlsx file in folder

I am trying to rename a series of excel files within a folder via Python that are in .xlsx format. To rename them, I need to get some information from each workbook first. I had trouble doing this as once I would get the information, I could not rename because the file was “in use by another process” so I built this workaround. It seems to work, except for the last file in the folder always gives me that same error of the file being “in use by another process”.