-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I insert a picture as embedded in a cell ? #417
Comments
When you perform this action in Excel it scales the image to fit the cell. It is also possible with You can do it yourself by using some library to get the X and Y pixel size of the the image and also the X and Y DPI. There are internal functions to do this in After that you need to scale the image (using the dimensions and DPI) to the pixel size of the cell. There is some code for that in the Rust version of the library that I wrote. See here. |
ok, thank you, I hope to add this feature in the future. |
@jmcnamara : The author is asking how to embed picture in cell. In latest excel there are 2 options to insert picture.
|
@sunilsabraham Could you attach an Excel example with an image embedded in a cell and a similar example with an image just inserted, and not embedded, for reference. |
@jmcnamara Please see the screen shot below. Just open excel and try to insert a picture and you will get 2 options. first one is to embed picture to a cell and excel will automatically scale the image. second one is to place image over a cell and that is the current implementation in libxlswriter. Old excel had only place over a cell may be upto 2016 version. If you can implement the embed in cell that would be great. so we dont need to scale the image and it automatically does according to row height etc. I am attaching an example file as well. |
@sunilsabraham Thanks for pointing that out. That is a useful feature. I'll try add it. |
Thanks. |
@jmcnamara I'd love the Place in cell feature too! Images placed in cells will scale according to column width/row height. As we can define the initial column width and row height, to accommodate our inserted images, cells shoudn't be hidden on file open. I think this produces a more natural and robust layout behaviour - e.g. when objects float over cells users can struggle with the overlap. |
Hi @jmcnamara I've been reading the openxml API reference docs (my first time), but the 'place in cell' xml format is not immediately obvious. So I have begun using an OOXML editor/viewer to see the difference between images placed in cells using typical drawing references vs an image embedded in a cell. |
Yes. I started working on it in December but then got sucked into some work on |
Hi John, |
Snippets to get image dimensions and DPIs for in-cell embedding. |
Note, there is already code like that in the library: https://github.com/jmcnamara/libxlsxwriter/blob/main/src/worksheet.c#L3885 It isn't public, by default, and I could make it public but the feature request is for a newer type of embedded image feature in Excel. |
Just a note that I've made some progress on this. I've implemented this feature in the Python and Perl versions of the library ( https://xlsxwriter.readthedocs.io/worksheet.html#embed_image |
Hi John, |
Yes. Probably. |
I want to insert a picture as embedded in a cell. How do I do that with libxlsxwriter? thank you
The text was updated successfully, but these errors were encountered: