Relative Content

Tag Archive for pythonopenpyxl

Adding multiple instances of an image into xlsx using openpyxl

I have a task to automate the generation of reports in Excel. One of the features of this report is that it is necessary to add pictures of products, the same ones several times on different sheets. When the manager made this report manually, they just copied the pictures from sheet to sheet and the size of the report was not very large. When I started to automate this report in python + openpyxl, I faced the problem that I can’t add the same picture twice – if I try to save this xlsx file, an error pops up:
ValueError: I/O operation on closed file.
I got around this problem by reopening the image file each time, but this led to the problem that the xlsx file now has many instances of the same image, which bloats the file size.

How do I format the numbers in a trendline equation using OpenPyXL?

I am using openpyxl to generate some figures in a spreadsheet. I have added the R^2 and trendline equations, however, I also want to format those numbers to show a higher number of significant figures. In the case of the trendline equation (exponential fit), I’d prefer to have four or five digits on the first term and nine in the exponential term in scientific notation, however, I’d settle for both numbers having nine digits; for R^2, I’d like five to six digits.

Copy cells with text and font-color with openpyxl?

I try to copy some cells with colored fonts from one worksheet to antoher using openpyxl.
The cell A1 is only colored – and the cell A2 is richtext-colored (so only a part of the cell is colored)

Need help creating a delete function to delete a selected row on a TreeView. The TreeView is populated from an excel sheet

Here is my Select_Item function. This selects the entire row and repopulates the Entry boxes for update. I can’t figure out how to create the delete_item to delete the entire row that’s been selected. Add_Item works great, Select_Item works great as well. I am using tkinter, and openpyxl. Also I know my code is sloppy but I have been learning python for about 4 months now.