0

I am creating an excel spreadsheet using pythons win32com module excel client. I wanted to add a logo to my excel spreadsheet report. So far I have managed to add the picture:

# Set a variable to an empty excel instance
excel = win32com.client.Dispatch("Excel.Application")

# Initialize a workbook within excel
book = excel.Workbooks.Add()

# Create sheet in book
sheet = book.Worksheets(1)

sheet.Pictures().Insert(r"G:\logos\Logo.jpg")

I've been pouring through the web and I cannot seem to find a way to access the position properties of the picture to move to it a particular place, nor can I find out how to access the sizing properties. Is there a help doc out there that has some examples that I cannot seem to find?

Oliver
  • 27,510
  • 9
  • 72
  • 103
Mike
  • 4,099
  • 17
  • 61
  • 83
  • I figured out how to set the Height and Width, but I'm at a lose as to how to place the picture in a particular location.... – Mike Mar 17 '14 at 21:16

1 Answers1

2

Try

cell = sheet.Cells(1,1)
pic = sheet.Pictures().Insert(r"G:\logos\Logo.jpg")
pic.Left = cell.Left + 20
pic.Top = cell.Top + 30

which will position your picture at 20 pixels right and 30 down from top left corner of given cell.

Regarding help, my reference is search for "excel interop " such as "excel interop range" or "excel interop picture" which leads to Picture object docs.

Oliver
  • 27,510
  • 9
  • 72
  • 103
  • Thanks Schollii! That's exactly what I needed. Also, thanks for the reference. I've bookmarked the page. – Mike Mar 18 '14 at 15:09