Export Picture with a precise size


I need to export a picture from my spreadsheet with the exact size of 590 x 380 pixels.

I copied and pasted as a picture with linking the cells that I want. When I copied and pasted in the Paint app, it works very well, but when I try to export using the chart method it always creates a picture with a different size and a very bad resolution.

I’d like to use the Daniel’s XL Toolbox API to export the picture.

My question is:
If I use the picture as the Selection, the exportselect function keeps the picture size?


Hi Eduardo,

yes, it should preserve the size. If you want to achieve an exact pixel size, you not only have to get the chart size correct, but also have to choose the appropriate DPI value.

If you want you can privately send me a sample file so I can play around a bit as well (provided I find time…).

Best regards


Hi Daniel,

Thanks for your reply.

I didn’t find a way to send the file privately. But I’ll share it in a google drive

In the folder you’ll find attached the sample file where I put the two methods:

The traditional, where I can keep the size I want but the quality is not good.

Using the toolbox, where either the size and the quality are wrong.

I also attached the pictures generated from them


Thanks again

Hi @Daniel,

Did you have a chance to have a look at my problem?


Dear Eduardo,

thanks for reminding me, I finally got around to looking at it. In order to obtain a good-quality picture, I had to scale up the resolution quite a bit. Exporting with 100 dpi and a width of 5.9 inch (which results in 590 pixels) the black-on-white text is not reproduced nicely. It gets worse when cranking up the dpi. With 1000 dpi and an export width of 5.9 inch (which results in 5900 pixels) the quality is good. However, to get to the desired number of pixels, a second step has to follow which reduces the exported image to 1/10. It’s a hack, it’s a workaround, but at least it is doable and should be possible to be accomplished programmatically (using ImageMagick or something similar).

The XL Toolbox uses the Windows graphics API to draw the exported image in memory. It’s strange that the font is drawn so differently depending on the resolution. It might have something to do with Windows trying to anti-alias small fonts (for example), but I never managed to change the aliasing and other settings; the corresponding commands just would not be respected by the graphics API. Unfortunately, there is little one can do aobut the drawing issues, it is purely a Windows thing…

Hope you can somehow get your desired workflow up and running!

Kind regards