Skip to Content
0

abap2xlsx - How to edit xlsx template from OAOR?

Nov 08, 2016 at 07:10 AM

205

avatar image
Former Member

Hi experts, I would like know if is possible to read a template xlsx from OAOR and edit it with abap2xlsx in background mode.

I have need to change single cells and insert new rows into my template being careful not to damage the images.

Best Regards,

AI

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Nov 08, 2016 at 08:02 AM
0

OAOR gives access to the documents in the Business Document Services (BDS). The API to get a document is the class CL_BDS_DOCUMENT_SET (can be called in background).

abap2xlsx can be called in background too.

Show 6 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you Sandra for your reply, I use abap2xlsx for read the file in background but I would like know how convert it for change value in a cell or insert new row with abap2xlsx. After change i need to save it in xlsx format in a folder on application server.

Do you have a example code?

Regards,

AI

0

abap2xlsx is supplied with many examples. The classes to instantiate ZCL_EXCEL from an Excel XSTRING implement ZIF_EXCEL_READER~LOAD, and the classes to get the XSTRING from an instance of ZCL_EXCEL implement ZIF_EXCEL_WRITER~WRITE_FILE.

0

Can you please provide any ABAP2XLSX demo example for this? I have the same requirement to modify the template from OAOR and it should run in background mode.

0

Search the web, there are so many examples. If you have an issue, then post a question in the forum.

0
Former Member
Sandra Rossi

Hi Sandra,

I didn't found any solution or demo about it. I drew the template directly with abap2xlsx.

AI

0
DATA file_table TYPE filetable.
DATA rc TYPE i.
DATA user_action TYPE i.
cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = file_table
rc = rc
user_action = user_action
EXCEPTIONS
OTHERS = 1
).
CHECK sy-subrc = 0.
CHECK user_action = cl_gui_frontend_services=>action_ok.
DATA data_tab TYPE TABLE OF x255.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = CONV #( file_table[ 1 ]-filename )
filetype = 'BIN'
IMPORTING
filelength = DATA(filelength)
CHANGING
data_tab = data_tab
EXCEPTIONS
OTHERS = 1
).
CHECK sy-subrc = 0.
DATA(reader) = NEW zcl_excel_reader_2007( ).
DATA(excel) = reader->zif_excel_reader~load( i_excel2007 = CONV #(
substring( val = REDUCE string( INIT x TYPE xstring FOR <x> IN data_tab NEXT x = x && <x> )
len = filelength * 2 ) ) ).
0