Comments (2)
Hello,
My suggestion:
Replace line:
lt_dfies = lo_tabdescr->get_ddic_field_list( ).
by:
lt_dfies = zcl_excel_common=>describe_structure( io_struct = lo_tabdescr ).
This method works with non DDIC structure, too
And i would prefer renaming lo_tabdescr to lo_structdescr
Thanks
Bernd
from abap2xlsx.
One possible solution is this one:
METHOD set_table.
DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr,
lr_data TYPE REF TO data,
lt_dfies TYPE ddfields,
lv_row_int TYPE zexcel_cell_row,
lv_column_int TYPE zexcel_cell_column,
lv_column_alpha TYPE zexcel_cell_column_alpha,
lv_cell_value TYPE zexcel_cell_value.
DATA lt_components TYPE abap_component_tab.
FIELD-SYMBOLS: <fs_table_line> TYPE any,
<fs_fldval> TYPE any,
<fs_dfies> TYPE dfies.
FIELD-SYMBOLS <fs_component> TYPE abap_componentdescr.
lv_column_int = lcl_excel_common=>convert_column2int( ip_top_left_column ).
lv_row_int = ip_top_left_row.
CREATE DATA lr_data LIKE LINE OF ip_table.
lo_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_components = lo_tabdescr->get_components( ).
IF ip_no_header = abap_false.
CALL METHOD lo_tabdescr->get_ddic_field_list
RECEIVING
p_field_list = lt_dfies
EXCEPTIONS
not_found = 1
no_ddic_type = 2
others = 3.
IF sy-subrc <> 0.
zcx_excel=>raise_text( 'SET_TABLE parameter IP_TABLE must have lines defined by a DDIC Structure' ).
ENDIF.
ENDIF.
* It is better to loop column by column
LOOP AT lt_components ASSIGNING <fs_component>.
lv_column_alpha = lcl_excel_common=>convert_column2alpha( lv_column_int ).
IF ip_no_header = abap_false.
" First of all write column header
READ TABLE lt_dfies ASSIGNING <fs_dfies> WITH KEY fieldname = <fs_component>-name.
IF sy-subrc = 0.
lv_cell_value = <fs_dfies>-scrtext_m.
set_cell( ip_column = lv_column_alpha
ip_row = lv_row_int
ip_value = lv_cell_value
ip_style = ip_hdr_style ).
ENDIF.
IF ip_transpose = abap_true.
ADD 1 TO lv_column_int.
ELSE.
ADD 1 TO lv_row_int.
ENDIF.
ENDIF.
LOOP AT ip_table ASSIGNING <fs_table_line>.
lv_column_alpha = lcl_excel_common=>convert_column2alpha( lv_column_int ).
ASSIGN COMPONENT <fs_component>-name OF STRUCTURE <fs_table_line> TO <fs_fldval>.
lv_cell_value = <fs_fldval>.
set_cell( ip_column = lv_column_alpha
ip_row = lv_row_int
ip_value = <fs_fldval> "lv_cell_value
ip_style = ip_body_style ).
IF ip_transpose = abap_true.
ADD 1 TO lv_column_int.
ELSE.
ADD 1 TO lv_row_int.
ENDIF.
ENDLOOP.
IF ip_transpose = abap_true.
lv_column_int = lcl_excel_common=>convert_column2int( ip_top_left_column ).
ADD 1 TO lv_row_int.
ELSE.
lv_row_int = ip_top_left_row.
ADD 1 TO lv_column_int.
ENDIF.
ENDLOOP.
ENDMETHOD. "SET_TABLE
from abap2xlsx.
Related Issues (20)
- Weird error message "Index out of bounds" if converting a not-date Excel value into an ABAP date field
- ZCL_EXCEL_WRITER_2007 Constructor for SAP_BASIS 701 HOT 5
- Excel Removed Records: Document Theme from /xl/workbook.xml part (Workbook) SAP_BASIS 701 HOT 1
- Warnings during abapGit import to SAP Cloud Platform (OTR, ZCX_EXCEL, ZEXCEL_TEMPLATE_GET_TYPES)
- Reader is freezing the wrong rows/columns HOT 2
- Reader ignores the zoom percentage
- Incorrect date format in excel sheets 2 & 3 from ZDEMO_EXCEL24 (SAP_BASIS 756)? HOT 4
- [Excel2007+] Pre-defined pictures are losing the move and size properties HOT 1
- BIND_TABLE and autofilter HOT 4
- Making Date as blank instead of '00.00.0000' in CSV export HOT 9
- Sometimes values of referenced Filed are empty HOT 1
- CX_SY_CONVERSION_NO_NUMBER because of conversion exit EXCRT HOT 6
- ZCL_EXCEL_WORKSHEET -> CONVERT_TO_TABLE drops initial excel lines HOT 8
- CX_SY_CONVERSION_NO_NUMBER exception in ZCL_EXCEL_READER_2007 method LOAD_WORKSHEET for multiple row spans HOT 1
- Use of Column Formula (zdemo_excel47) generates corrupted Excel HOT 10
- ZCL_EXCEL_WORKSHEET -> CONVERT_TO_TABLE wrong results if empty lines HOT 2
- Incorrect cell value when generating Excel using write_file and digits with data type "s" HOT 4
- CONVT_NO_NUMBER in ZCL_EXCEL_READER_2007=>LOAD_WORKSHEET HOT 4
- convert_to_table may produce zcx_excel/invalid time with some time values
- Reorganize zcl_excel_common unit tests, one method per test and define several test classes instead of one
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abap2xlsx.