question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with Image Insertion on top of Hidden Columns

See original GitHub issue

Hi,

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:

image

However, if I select cell A1 and then manually insert the image via the excel GUI then all is well:

image

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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcnamaracommented, Jun 26, 2019

Thanks. That is definitely a bug. I’ll look into it.

0reactions
StevenRSellerscommented, Jun 26, 2019

That’s great - thanks for the quick resolution; using {'hidden': True} is working for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An image in a header or a footer may overlap into the data ...
This issue occurs because the image is not automatically resized to fit inside the header or footer section when you place an image...
Read more >
Insert an Image into an Excel Cell - Lock it to the ... - YouTube
This video demonstrates how to embed an image in a cell so that when you sort or filter or insert columns and rows...
Read more >
Buttons For Inserting Images Or Charts In Excel Greyed Out?
You want to insert a chart or image in Excel but the buttons are greyed out? Here are the possible reasons and the...
Read more >
How to insert picture in Excel cell, comment, header and footer
The tutorial shows different ways to insert an image in Excel worksheet, fit a picture in a cell, add it to a comment,...
Read more >
How to hide picture when hiding rows or columns in Excel?
If you apply the above method in this article to change the picture's prperties for hiding the images when hiding columns and rows,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found