Skip to content

Instantly share code, notes, and snippets.

@kjosib
Created July 9, 2015 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjosib/97564bb295dd6e7f3b7a to your computer and use it in GitHub Desktop.
Save kjosib/97564bb295dd6e7f3b7a to your computer and use it in GitHub Desktop.
# CauseBug.py
# Run this program. Open the generated file ('bugged.xlsx') in Excel 2007,
# hide row 8 or something, and save it back again. Close it, and re-open.
# It will cause the graphic to disappear and be considered as "corruption".
import xlsxwriter
workbook = xlsxwriter.Workbook('bugged.xlsx')
sheet = workbook.add_worksheet('Sheet1')
## Please note: test.png is 208 x 49, made in ms-paint and arbitrary.
sheet.insert_image(0,10, 'test.png', {'x_offset':-210, 'y_offset':1})
workbook.close()
## SENSITIVITY ANALYSIS:
# It seems to save OK if the x_offset is at least -207, which puts at least
# one pixel of the image within the host cell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment