diff --git a/src/demos/zdemo_excel15_01.w3mi.data.xlsx b/src/demos/zdemo_excel15_01.w3mi.data.xlsx index 2332ea9..45a0fd9 100644 Binary files a/src/demos/zdemo_excel15_01.w3mi.data.xlsx and b/src/demos/zdemo_excel15_01.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_01.w3mi.xml b/src/demos/zdemo_excel15_01.w3mi.xml index 40e8248..d82bcf1 100644 --- a/src/demos/zdemo_excel15_01.w3mi.xml +++ b/src/demos/zdemo_excel15_01.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_01 filename + 15_01_HelloWorldFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_02.w3mi.data.xlsx b/src/demos/zdemo_excel15_02.w3mi.data.xlsx index dae1e6b..9c8995e 100644 Binary files a/src/demos/zdemo_excel15_02.w3mi.data.xlsx and b/src/demos/zdemo_excel15_02.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_02.w3mi.xml b/src/demos/zdemo_excel15_02.w3mi.xml index 42a5866..86884df 100644 --- a/src/demos/zdemo_excel15_02.w3mi.xml +++ b/src/demos/zdemo_excel15_02.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_02 filename + 15_02_StylesFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_03.w3mi.data.xlsx b/src/demos/zdemo_excel15_03.w3mi.data.xlsx index 2d8f791..2e189eb 100644 Binary files a/src/demos/zdemo_excel15_03.w3mi.data.xlsx and b/src/demos/zdemo_excel15_03.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_03.w3mi.xml b/src/demos/zdemo_excel15_03.w3mi.xml index 9129913..96e1dba 100644 --- a/src/demos/zdemo_excel15_03.w3mi.xml +++ b/src/demos/zdemo_excel15_03.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_03 filename + 15_03_iTabFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_04.w3mi.data.xlsx b/src/demos/zdemo_excel15_04.w3mi.data.xlsx index c589a7f..314a14f 100644 Binary files a/src/demos/zdemo_excel15_04.w3mi.data.xlsx and b/src/demos/zdemo_excel15_04.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_04.w3mi.xml b/src/demos/zdemo_excel15_04.w3mi.xml index 95e46c1..ca84553 100644 --- a/src/demos/zdemo_excel15_04.w3mi.xml +++ b/src/demos/zdemo_excel15_04.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_04 filename + 15_04_SheetsFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_05.w3mi.data.xlsx b/src/demos/zdemo_excel15_05.w3mi.data.xlsx index befd4f7..add90d3 100644 Binary files a/src/demos/zdemo_excel15_05.w3mi.data.xlsx and b/src/demos/zdemo_excel15_05.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_05.w3mi.xml b/src/demos/zdemo_excel15_05.w3mi.xml index 6d97620..787d713 100644 --- a/src/demos/zdemo_excel15_05.w3mi.xml +++ b/src/demos/zdemo_excel15_05.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_05 filename + 15_05_ConditionalFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_07.w3mi.data.xlsx b/src/demos/zdemo_excel15_07.w3mi.data.xlsx index ede2a73..7698e22 100644 Binary files a/src/demos/zdemo_excel15_07.w3mi.data.xlsx and b/src/demos/zdemo_excel15_07.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_07.w3mi.xml b/src/demos/zdemo_excel15_07.w3mi.xml index a8491e5..9b70936 100644 --- a/src/demos/zdemo_excel15_07.w3mi.xml +++ b/src/demos/zdemo_excel15_07.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_07 filename + 15_07_ConditionalAllFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_08.w3mi.data.xlsx b/src/demos/zdemo_excel15_08.w3mi.data.xlsx index 23f4e07..aff3d2c 100644 Binary files a/src/demos/zdemo_excel15_08.w3mi.data.xlsx and b/src/demos/zdemo_excel15_08.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_08.w3mi.xml b/src/demos/zdemo_excel15_08.w3mi.xml index a3bdd6a..1e5fd1f 100644 --- a/src/demos/zdemo_excel15_08.w3mi.xml +++ b/src/demos/zdemo_excel15_08.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_08 filename + 15_08_RangeFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_13.w3mi.data.xlsx b/src/demos/zdemo_excel15_13.w3mi.data.xlsx index 3c38c25..d0a6515 100644 Binary files a/src/demos/zdemo_excel15_13.w3mi.data.xlsx and b/src/demos/zdemo_excel15_13.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_13.w3mi.xml b/src/demos/zdemo_excel15_13.w3mi.xml index 4044b96..fc9a4f3 100644 --- a/src/demos/zdemo_excel15_13.w3mi.xml +++ b/src/demos/zdemo_excel15_13.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_13 filename + 15_13_MergedCellsFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_24.w3mi.data.xlsx b/src/demos/zdemo_excel15_24.w3mi.data.xlsx index 9f5361a..cb9c2f0 100644 Binary files a/src/demos/zdemo_excel15_24.w3mi.data.xlsx and b/src/demos/zdemo_excel15_24.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_24.w3mi.xml b/src/demos/zdemo_excel15_24.w3mi.xml index 876e98d..9c6f35e 100644 --- a/src/demos/zdemo_excel15_24.w3mi.xml +++ b/src/demos/zdemo_excel15_24.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_24 filename + 15_24_Sheets_with_different_default_date_formatsFromReader.xlsx MI diff --git a/src/demos/zdemo_excel15_31.w3mi.data.xlsx b/src/demos/zdemo_excel15_31.w3mi.data.xlsx index 689e3b9..40655cd 100644 Binary files a/src/demos/zdemo_excel15_31.w3mi.data.xlsx and b/src/demos/zdemo_excel15_31.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel15_31.w3mi.xml b/src/demos/zdemo_excel15_31.w3mi.xml index eed800e..c3135a9 100644 --- a/src/demos/zdemo_excel15_31.w3mi.xml +++ b/src/demos/zdemo_excel15_31.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL15_31 filename + 15_31_AutosizeWithDifferentFontSizesFromReader.xlsx MI diff --git a/src/demos/zdemo_excel3.prog.abap b/src/demos/zdemo_excel3.prog.abap index c51bb05..1c4f24e 100644 --- a/src/demos/zdemo_excel3.prog.abap +++ b/src/demos/zdemo_excel3.prog.abap @@ -8,7 +8,8 @@ REPORT zdemo_excel3. -TYPES: ty_sflight_lines TYPE TABLE OF sflight. +TYPES: ty_sflight_lines TYPE TABLE OF sflight, + ty_scarr_lines TYPE TABLE OF scarr. DATA: lo_excel TYPE REF TO zcl_excel, lo_worksheet TYPE REF TO zcl_excel_worksheet, @@ -18,12 +19,12 @@ DATA: ls_table_settings TYPE zexcel_s_table_settings. DATA: lv_title TYPE zexcel_sheet_title, - lt_carr TYPE TABLE OF scarr, + lt_carr TYPE ty_scarr_lines, row TYPE zexcel_cell_row VALUE 2, ls_error TYPE zcl_excel_worksheet=>mty_s_ignored_errors, lt_error TYPE zcl_excel_worksheet=>mty_th_ignored_errors, lo_range TYPE REF TO zcl_excel_range. -DATA: lo_data_validation TYPE REF TO zcl_excel_data_validation. +DATA: lo_data_validation TYPE REF TO zcl_excel_data_validation. FIELD-SYMBOLS: LIKE LINE OF lt_carr. CONSTANTS: c_airlines TYPE string VALUE 'Airlines'. @@ -60,6 +61,11 @@ START-OF-SELECTION. lo_worksheet->bind_table( ip_table = lt_test is_table_settings = ls_table_settings ). + IF p_checkr = abap_true. + PERFORM set_column_headers USING lo_worksheet + 'Airline;Flight Number;Date;Airfare;Airline Currency;Plane Type;Max. capacity econ.;Occupied econ.;Total;Max. capacity bus.;Occupied bus.;Max. capacity 1st;Occupied 1st'. + ENDIF. + lo_worksheet->freeze_panes( ip_num_rows = 3 ). "freeze column headers when scrolling IF lines( lt_test ) >= 1. ls_error-cell_coords = |B2:B{ lines( lt_test ) + 1 }|. @@ -75,7 +81,11 @@ START-OF-SELECTION. lv_title = 'Data Validation'. lo_worksheet->set_title( lv_title ). lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = c_airlines ). - SELECT * FROM scarr INTO TABLE lt_carr. "#EC CI_NOWHERE + IF p_checkr = abap_true. + PERFORM load_scarr_data_for_checker CHANGING lt_carr. + ELSE. + SELECT * FROM scarr INTO TABLE lt_carr. "#EC CI_NOWHERE + ENDIF. LOOP AT lt_carr ASSIGNING . lo_worksheet->set_cell( ip_row = row ip_column = 'A' ip_value = -carrid ). row = row + 1. @@ -104,47 +114,85 @@ START-OF-SELECTION. FORM load_fixed_data_for_checker CHANGING ct_test TYPE ty_sflight_lines. - DATA: lt_lines TYPE TABLE OF string, - lv_line TYPE string, - lt_fields TYPE TABLE OF string, - lv_comp TYPE i, - lv_field TYPE string, - ls_test TYPE sflight. - FIELD-SYMBOLS: TYPE simple. + DATA: lt_lines TYPE TABLE OF string. - APPEND 'AA 0017 20171219 422 USD 747-400 385 371 191334 31 28 21 21' TO lt_lines. - APPEND 'AA 0017 20180309 422 USD 747-400 385 365 189984 31 29 21 20' TO lt_lines. - APPEND 'AA 0017 20180528 422 USD 747-400 385 374 193482 31 30 21 20' TO lt_lines. - APPEND 'AA 0017 20180816 422 USD 747-400 385 372 193127 31 30 21 20' TO lt_lines. - APPEND 'AA 0017 20181104 422 USD 747-400 385 44 23908 31 4 21 3' TO lt_lines. - APPEND 'AA 0017 20190123 422 USD 747-400 385 40 20347 31 3 21 2' TO lt_lines. - APPEND 'AZ 0555 20171219 185 EUR 737-800 140 133 32143 12 12 10 10' TO lt_lines. - APPEND 'AZ 0555 20180309 185 EUR 737-800 140 137 32595 12 12 10 10' TO lt_lines. - APPEND 'AZ 0555 20180528 185 EUR 737-800 140 134 31899 12 11 10 10' TO lt_lines. - APPEND 'AZ 0555 20180816 185 EUR 737-800 140 128 29775 12 10 10 9' TO lt_lines. - APPEND 'AZ 0555 20181104 185 EUR 737-800 140 0 0 12 0 10 0' TO lt_lines. - APPEND 'AZ 0555 20190123 185 EUR 737-800 140 23 5392 12 1 10 2' TO lt_lines. - APPEND 'AZ 0789 20171219 1030 EUR 767-200 260 250 307176 21 20 11 11' TO lt_lines. - APPEND 'AZ 0789 20180309 1030 EUR 767-200 260 252 306054 21 20 11 10' TO lt_lines. - APPEND 'AZ 0789 20180528 1030 EUR 767-200 260 252 307063 21 20 11 10' TO lt_lines. - APPEND 'AZ 0789 20180816 1030 EUR 767-200 260 249 300739 21 19 11 10' TO lt_lines. - APPEND 'AZ 0789 20181104 1030 EUR 767-200 260 104 127647 21 8 11 5' TO lt_lines. - APPEND 'AZ 0789 20190123 1030 EUR 767-200 260 18 22268 21 1 11 1' TO lt_lines. - APPEND 'DL 0106 20171217 611 USD A380-800 475 458 324379 30 29 20 20' TO lt_lines. - APPEND 'DL 0106 20180307 611 USD A380-800 475 458 324330 30 30 20 20' TO lt_lines. - APPEND 'DL 0106 20180526 611 USD A380-800 475 459 328149 30 29 20 20' TO lt_lines. - APPEND 'DL 0106 20180814 611 USD A380-800 475 462 326805 30 30 20 18' TO lt_lines. - APPEND 'DL 0106 20181102 611 USD A380-800 475 167 115554 30 10 20 6' TO lt_lines. - APPEND 'DL 0106 20190121 611 USD A380-800 475 11 9073 30 1 20 1' TO lt_lines. - LOOP AT lt_lines INTO lv_line. - CONDENSE lv_line. - SPLIT lv_line AT space INTO TABLE lt_fields. + APPEND 'AA;0017;20171219; 422;USD;747-400 ;385;371;191334;31;28;21;21' TO lt_lines. + APPEND 'AA;0017;20180309; 422;USD;747-400 ;385;365;189984;31;29;21;20' TO lt_lines. + APPEND 'AA;0017;20180528; 422;USD;747-400 ;385;374;193482;31;30;21;20' TO lt_lines. + APPEND 'AA;0017;20180816; 422;USD;747-400 ;385;372;193127;31;30;21;20' TO lt_lines. + APPEND 'AA;0017;20181104; 422;USD;747-400 ;385; 44; 23908;31; 4;21; 3' TO lt_lines. + APPEND 'AA;0017;20190123; 422;USD;747-400 ;385; 40; 20347;31; 3;21; 2' TO lt_lines. + APPEND 'AZ;0555;20171219; 185;EUR;737-800 ;140;133; 32143;12;12;10;10' TO lt_lines. + APPEND 'AZ;0555;20180309; 185;EUR;737-800 ;140;137; 32595;12;12;10;10' TO lt_lines. + APPEND 'AZ;0555;20180528; 185;EUR;737-800 ;140;134; 31899;12;11;10;10' TO lt_lines. + APPEND 'AZ;0555;20180816; 185;EUR;737-800 ;140;128; 29775;12;10;10; 9' TO lt_lines. + APPEND 'AZ;0555;20181104; 185;EUR;737-800 ;140; 0; 0;12; 0;10; 0' TO lt_lines. + APPEND 'AZ;0555;20190123; 185;EUR;737-800 ;140; 23; 5392;12; 1;10; 2' TO lt_lines. + APPEND 'AZ;0789;20171219;1030;EUR;767-200 ;260;250;307176;21;20;11;11' TO lt_lines. + APPEND 'AZ;0789;20180309;1030;EUR;767-200 ;260;252;306054;21;20;11;10' TO lt_lines. + APPEND 'AZ;0789;20180528;1030;EUR;767-200 ;260;252;307063;21;20;11;10' TO lt_lines. + APPEND 'AZ;0789;20180816;1030;EUR;767-200 ;260;249;300739;21;19;11;10' TO lt_lines. + APPEND 'AZ;0789;20181104;1030;EUR;767-200 ;260;104;127647;21; 8;11; 5' TO lt_lines. + APPEND 'AZ;0789;20190123;1030;EUR;767-200 ;260; 18; 22268;21; 1;11; 1' TO lt_lines. + APPEND 'DL;0106;20171217; 611;USD;A380-800;475;458;324379;30;29;20;20' TO lt_lines. + APPEND 'DL;0106;20180307; 611;USD;A380-800;475;458;324330;30;30;20;20' TO lt_lines. + APPEND 'DL;0106;20180526; 611;USD;A380-800;475;459;328149;30;29;20;20' TO lt_lines. + APPEND 'DL;0106;20180814; 611;USD;A380-800;475;462;326805;30;30;20;18' TO lt_lines. + APPEND 'DL;0106;20181102; 611;USD;A380-800;475;167;115554;30;10;20; 6' TO lt_lines. + APPEND 'DL;0106;20190121; 611;USD;A380-800;475; 11; 9073;30; 1;20; 1' TO lt_lines. + + PERFORM load_data USING lt_lines CHANGING ct_test. +ENDFORM. + +FORM load_scarr_data_for_checker CHANGING ct_scarr TYPE ty_scarr_lines. + DATA: lt_lines TYPE TABLE OF string. + + APPEND 'AA;American Airlines;USD;http://www.aa.com ' TO lt_lines. + APPEND 'AZ;Alitalia ;EUR;http://www.alitalia.it ' TO lt_lines. + APPEND 'DL;Delta Airlines ;USD;http://www.delta-air.com' TO lt_lines. + + PERFORM load_data USING lt_lines CHANGING ct_scarr. +ENDFORM. + +FORM load_data USING it_data TYPE table CHANGING ct_data TYPE table. + DATA: lv_line TYPE string, + lt_fields TYPE TABLE OF string, + lv_comp TYPE i, + lv_field TYPE string, + lv_ref_line TYPE REF TO data. + FIELD-SYMBOLS: + TYPE simple, + TYPE any. + + CREATE DATA lv_ref_line LIKE LINE OF ct_data. + ASSIGN lv_ref_line->* TO . + + LOOP AT it_data INTO lv_line. + CLEAR . + SPLIT lv_line AT ';' INTO TABLE lt_fields. lv_comp = 2. LOOP AT lt_fields INTO lv_field. - ASSIGN COMPONENT lv_comp OF STRUCTURE ls_test TO . + ASSIGN COMPONENT lv_comp OF STRUCTURE TO . = lv_field. lv_comp = lv_comp + 1. ENDLOOP. - APPEND ls_test TO ct_test. + APPEND TO ct_data. ENDLOOP. ENDFORM. + +FORM set_column_headers + USING io_worksheet TYPE REF TO zcl_excel_worksheet + iv_headers TYPE csequence + RAISING zcx_excel. + + DATA: lt_headers TYPE TABLE OF string, + lv_header TYPE string, + lv_tabix TYPE i. + + SPLIT iv_headers AT ';' INTO TABLE lt_headers. + LOOP AT lt_headers INTO lv_header. + lv_tabix = sy-tabix. + io_worksheet->set_cell( ip_row = 1 ip_column = lv_tabix ip_value = lv_header ). + ENDLOOP. + +ENDFORM. diff --git a/src/demos/zdemo_excel3.w3mi.data.xlsx b/src/demos/zdemo_excel3.w3mi.data.xlsx index 26e3c8a..46eadf3 100644 Binary files a/src/demos/zdemo_excel3.w3mi.data.xlsx and b/src/demos/zdemo_excel3.w3mi.data.xlsx differ diff --git a/src/demos/zdemo_excel3.w3mi.xml b/src/demos/zdemo_excel3.w3mi.xml index 051eff5..680c2c0 100644 --- a/src/demos/zdemo_excel3.w3mi.xml +++ b/src/demos/zdemo_excel3.w3mi.xml @@ -15,6 +15,7 @@ MI ZDEMO_EXCEL3 filename + 03_iTab.xlsx MI diff --git a/src/demos/zdemo_excel33.prog.abap b/src/demos/zdemo_excel33.prog.abap index adfe106..8e3add3 100644 --- a/src/demos/zdemo_excel33.prog.abap +++ b/src/demos/zdemo_excel33.prog.abap @@ -46,6 +46,7 @@ START-OF-SELECTION. io_worksheet = lo_worksheet CHANGING co_excel = lo_excel ) . + PERFORM set_column_headers USING lo_worksheet 'Client;Language;Country;Name;Nationality;Long name;Nationality'. lo_autofilter = lo_excel->add_new_autofilter( io_sheet = lo_worksheet ) . @@ -94,3 +95,20 @@ FORM load_fixed_data CHANGING ct_test TYPE ty_t005t_lines. APPEND ls_test TO ct_test. ENDLOOP. ENDFORM. + +FORM set_column_headers + USING io_worksheet TYPE REF TO zcl_excel_worksheet + iv_headers TYPE csequence + RAISING zcx_excel. + + DATA: lt_headers TYPE TABLE OF string, + lv_header TYPE string, + lv_tabix TYPE i. + + SPLIT iv_headers AT ';' INTO TABLE lt_headers. + LOOP AT lt_headers INTO lv_header. + lv_tabix = sy-tabix. + io_worksheet->set_cell( ip_row = 1 ip_column = lv_tabix ip_value = lv_header ). + ENDLOOP. + +ENDFORM.