Skip to content
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

WRITER_2007 is not able to work with custom tables #1273

Open
hamida-ashna opened this issue Sep 17, 2024 · 4 comments
Open

WRITER_2007 is not able to work with custom tables #1273

hamida-ashna opened this issue Sep 17, 2024 · 4 comments

Comments

@hamida-ashna
Copy link

Hello, everyone.

While working with WRITER_2007, I observed that it only supports built-in Excel tables and cannot handle custom tables.

Case: I worked with an Excel file that contained custom tables. After reading and modifying the data, I saved it back to the file, but noticed that all the custom table styles were removed by the writer.

Before writing the data:
image

After writing the data:
image

C_AUFNR_KSTAR_MAP3.xlsx

Does anyone have any advice?

Thanks in advance.

@sandraros
Copy link
Collaborator

I'm not sure, it can be a problem to extend the tables of an existing workbook, abap2xlsx is better at creating from scratch. There are several ways to handle different kinds of tables. Are you using BIND_TABLE? Please post a minimal code to reproduce. Thank you.

@hamida-ashna
Copy link
Author

@sandraros thank you for your reply.
I tried bot BIND_TABLE and SET_TABLE, but with both of them I had the same problem.

Here is a sample code snippet from what I want:

DATA:
lo_writer TYPE REF TO zcl_excel_writer_2007,
lo_reader TYPE REF TO zcl_excel_reader_2007,
lo_excel TYPE REF TO zcl_excel,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_columns TYPE REF TO zcl_excel_columns,
lo_column TYPE REF TO zcl_excel_column,
lo_style TYPE REF TO zcl_excel_style,
sheet_id TYPE i.

" Instantiates Excel reader object.
CREATE OBJECT lo_reader TYPE /orbit/cl_x_reader_2007.

" Loads data from provided xstring in /ALLEVO/CL_N_EXCEL format
lo_excel = lo_reader->/orbit/if_x_reader~load( excel_data ).

lo_worksheet = lo_excel->get_worksheet_by_index( iv_index = 1 ).

lo_worksheet->set_table(
ip_table = it_data
ip_table_title = mv_tablename
ip_top_left_column = min_col
ip_top_left_row = row ).

" Save the changes to the Excel file
lo_excel->save

  • Is it possible to extend the tables of the existing workbook (locally)?

@gregorwolf
Copy link
Collaborator

Hi @hamida-ashna,

So do I get your request right:

  • You have C_AUFNR_KSTAR_MAP3.xlsx as your template
  • This is loaded into abap2xlsx using the reader class
  • You want to add data from SAP to it
  • use the writer to export the XLSX

As you mention the formatting is lost in the exported XLSX. Then you found a missing functionality in abap2xlsx. You're very welcome to contribute a fix for it.

@hamida-ashna
Copy link
Author

Hi @gregorwolf,
Yes, you understood my request correctly.
I will try my best into contributing. But do you have any suggestion for this enhancement or how we can solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants