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.

Feature request: insert_image to insert svg file

See original GitHub issue

Hi,
I am trying to put a svg file into the excel file but it seems svgs are not supported.

I haven’t found any workaround. Excel does support svg so it would be cool to get this feature.

  File "C:\Users\800xAAdmin\AppData\Local\Programs\Python\Python37\lib\site-packages\xlsxwriter\workbook.py", line 1204, in _get_image_properties
    "%s: Unknown or unsupported image file format." % filename)
xlsxwriter.exceptions.UnsupportedImageFormat: data/svg/Drive.svg: Unknown or unsupported image file format.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
jmcnamaracommented, Mar 25, 2019

Actually, after refreshing my memory since the last time I looked at this, the height and width are generally available (although the units change) but I had a hard time coming up with a matching DPI based on the viewbox.

I may look at it again. Particularly if this gets some more +1s.

1reaction
jmcnamaracommented, Sep 20, 2020

I’ve looked into this in a bit more detail and I don’t think I can support SVG files in XlsxWriter. There are a number of technical issues that contribute to this:

  • XlsxWriter needs to be able to determine the height, width and DPI for an image in order to position and scale it correctly in the appropriate Excel XML files. For SVG this seems hard. Particularly the DPI. However that isn’t a blocker.
  • SVG images weren’t supported by Excel2007 so I can’t generated sample files to use in test programs. This is more or less a blocker since image handling requires a lot of testing. (There are currently 107 tests that compare XlsxWriter output files containing images with Xlsx files generated in Excel).
  • Excel versions that do support SVG do so by converting the image to a PNG and storing both the SVG and PNG in the xlsx file. This allows older versions of Excel to display the PNG. (Also, as far as I can see, the newer Excel versions that support SVGs also display the PNG version, or at least reference the PNG version from the worksheet. They may just keep the SVG version around for export.) This is a blocker since XlsxWriter would have to convert the SVG to PNG and store both. This would need to happen via a third party module, which presumably is what user who needs to insert SVG images in XlsxWriter would do anyway.

So overall this is a can’t fix/won’t fix. Sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploaded SVG as a image (#24937) · Issues - GitLab.org
When user drag file into textarea for comment, GitLab will upload it and insert image or link into textarea. Currently SVG files are...
Read more >
Using SVG | CSS-Tricks
SVG is an image format for vector graphics. It literally means Scalable Vector Graphics. Basically, what you work with in Adobe Illustrator.
Read more >
Add SVG image format within | #dominoforever | Product Ideas ...
Add SVG image format within the httpd.conf file. SVG graphics are more and more in common use these days. For Domino web applications...
Read more >
Add SVG to Word DOC & Avoid SVG Image to EMF Metafile ...
The first image in the DOCX file is the SVG added using Aspose. ... There is feature request regarding inserting SVG the same...
Read more >
Adding Images, Fonts, and Files - Create React App
Note: this feature is available with react-scripts@2.0.0 and higher, and react@16.3.0 and higher. One way to add SVG files was described in the ......
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