I was asked to develope an Excel file containing Material data and an image of it next to them.
I chose to use the spreadsheet solution to create the file, but I have a problem with the images as they have been stored as BDS documents.
Does anyone knows how to insert this kind of images in an Excel file built from an abap program?
The basic idea is first to read the image from the BDS, you'll get the binary object in a variable, and secondly use abap2xlsx tool to build your Excel file and load your binary object into it amongst many other things (no doubt that there is a class/method for including images).
For the first one, you should search the forum for "get BDS document" (I personally use cl_bds_document_set=>get_with_table), and the second one can be retrieved from Code Exchange.
You can also use OLE to do this.
Having said that, the above post by Clemens and Sandra is definitely the easiest way. Also, this can be done in background.
You can use the below methods, if you are having issues installing the abap2xlsx package in your system.
1) Convert your BDS document to BMP.
2) Save that to a folder in presentation server.
3) Use Shapes in OLE to attach that picture to your excel sheet.
I read about the OLE solution but I never used that and - as I wrote Sandra too - I need to work with a template I saved in BDS too and I did not know if I could use it with the OLE solution.
Anyway, I already developed a temporary solution similar to what you suggested, that is to say that I saved a copy of the BDS files on a temporary directory and I add them in my Excel file with a macro I saved on the template. The solution, though, is quite "unelegant" and risky, that's why I wish I could use a better one.
Anyway thank you too.