Issue with Image Insertion on top of Hidden Columns
See original GitHub issueHi,
I am using XlsxWriter to insert an image on top of columns that may or may not be hidden (this is at user discretion). When I insert an image on top of a hidden column then the image is re-sized. I do not want this to happen. I expected that using the ‘object_position’ argument and supplying option 3 (‘don’t move or size with cells’) would solve the problem. But, in fact, it seems that none of the ‘image_position’ options resolve the behaviour.
I believe that this behaviour is different to the default behaviour of MS Excel, and accordingly I suspect that this is a bug. However, I am happy for someone to point out if i’m doing something incorrectly.
I am using Python version 3.7.0 and XlsxWriter 1.1.8 and Excel version 2016 MSO (16.0.4738.1000) 32-bit.
Here’s a minimal illustration:
import xlsxwriter
workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet()
worksheet.insert_image('A1', 'cat.jpg', {'object_position': 1})
worksheet.insert_image('A12', 'cat.jpg', {'object_position': 2})
worksheet.insert_image('A24', 'cat.jpg', {'object_position': 3})
worksheet.insert_image('A36', 'cat.jpg', {'object_position': 4})
worksheet.set_column('B:D', None, None, {'hidden': 1})
workbook.close()
This produces an excel in which ALL images are horizontally crushed:
However, if I select cell A1 and then manually insert the image via the excel GUI then all is well:
I note that this problem is very similar to issue #618 - here though I actually want the ‘unwanted’ behaviour from #618. Looking at the associated commit it looks like ‘object_position’ argument 1 is intended to preserve this behaviour, but this doesn’t work for me - as shown above.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks. That is definitely a bug. I’ll look into it.
That’s great - thanks for the quick resolution; using
{'hidden': True}
is working for me.