--
You received this message because you are subscribed to a topic in the Google Groups "openpyxl-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpyxl-users/1auXBiDlzHk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpyxl-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from openpyxl.drawing.spreadsheet_drawing import TwoCellAnchor, AnchorMarker
from openpyxl.drawing.drawing import Drawing
@property
def anchor(self):
anchor = self._anchor
return anchor
Drawing.anchor = anchor
from openpyxl.drawing.image import Image
def _anchor(self, anchor):
self.anchortype = 'twoCell'
self.drawing._anchor = anchor
Image.anchor = _anchor
wb = Workbook()
ws = wb.active
anchor = TwoCellAnchor(_from=AnchorMarker(row=2, col=2), to=AnchorMarker(row=3, col=3))
img = Image('test.png')
img.anchor(anchor)
ws.add_image(img)
wb.save('test.xlsx')
self._write_images(archive)
self._write_worksheets(archive)
self._write_worksheets(archive)
self._write_images(archive)
from openpyxl import Workbook
from openpyxl.drawing.spreadsheet_drawing import OneCellAnchor, AnchorMarker
from openpyxl.drawing.drawing import Drawing
property
def anchor(self):
anchor = self._anchor
return anchor
Drawing.anchor = anchor
from openpyxl.drawing.image import Image
def _anchor(self, anchor):
self.anchortype = 'oneCell'
self.drawing._anchor = anchor
Image.anchor = _anchor
wb = Workbook()
ws = wb.active
anchor = OneCellAnchor(_from=AnchorMarker(row=2, col=2, colOff=0))
img = Image('test.png')
img.anchor(anchor)
ws.add_image(img)
wb.save('test.xlsx')
but I got:
Traceback (most recent call last):
File "test2.py", line 26, in <module>
wb.save('test.xlsx')
File "/Library/Python/2.7/site-packages/openpyxl/workbook/workbook.py", line 339, in save
save_workbook(self, filename)
File "/Library/Python/2.7/site-packages/openpyxl/writer/excel.py", line 268, in save_workbook
writer.save(filename)
File "/Library/Python/2.7/site-packages/openpyxl/writer/excel.py", line 250, in save
self.write_data()
File "/Library/Python/2.7/site-packages/openpyxl/writer/excel.py", line 81, in write_data
self._write_worksheets()
File "/Library/Python/2.7/site-packages/openpyxl/writer/excel.py", line 206, in _write_worksheets
self._write_drawing(ws._drawing)
File "/Library/Python/2.7/site-packages/openpyxl/writer/excel.py", line 145, in _write_drawing
self.archive.writestr(drawing.path[1:], tostring(drawing._write()))
File "/Library/Python/2.7/site-packages/openpyxl/drawing/spreadsheet_drawing.py", line 274, in _write
anchor.pic = self._picture_frame(idx)
AttributeError: 'instancemethod' object has no attribute 'pic'
Has someone any idea ?
Thanks in advance for any clue.
P.-A. Moret