Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert an image stored in BDS within an Excel File

Former Member
0 Kudos

Hi everybody,

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?

Thank you

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

Hi,

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.

Regards,

Sandra

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos

Hi,

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.

Regards,

Sandra

0 Kudos

ZCL_EXCEL_WRITER_2007->CREATE_XL_DRAWINGS( ... )

0 Kudos

Yes I already used the abap2xlsx tool but never with a template, and as I have to use a template in this case I could not use the tool you suggested..

Thank you anyway

Former Member
0 Kudos

Hi,

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.

http://wiki.sdn.sap.com/wiki/display/Community/Insert+Picture+Image+in+Excel+using+OLE+Automation

Thanks,

Shambu

0 Kudos

Hi,

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.