* first part

* second and last part

Co-authored-by: sandraros <sandra.rossi@gmail.com>
This commit is contained in:
sandraros 2021-11-28 20:25:35 +01:00 committed by GitHub
parent dbd260da2c
commit d7011f715c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 677 additions and 677 deletions

View File

@ -225,7 +225,7 @@ FORM write_file RAISING zcx_excel.
RECEIVING
et_solix = lt_file.
l_bytecount = XSTRLEN( l_file ).
l_bytecount = xstrlen( l_file ).
ELSE.
" Convert to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

View File

@ -15,60 +15,60 @@ REPORT zdemo_excel_fill_template.
* on the Excel file ZDEMO_EXCEL_TEMPLATE
* from SMW0.
*=================
TYPES t_number TYPE p length 16 decimals 4.
TYPES t_number TYPE p LENGTH 16 DECIMALS 4.
TYPES:
begin of t_TABLE1,
PERSON type string,
SALARY type t_number,
end of t_TABLE1,
BEGIN OF t_table1,
person TYPE string,
salary TYPE t_number,
END OF t_table1,
tt_TABLE1 type standard table of t_TABLE1 with default key,
tt_table1 TYPE STANDARD TABLE OF t_table1 WITH DEFAULT KEY,
begin of t_LINE1,
CARRID type string,
CONNID type string,
FLDATE type d,
PRICE type t_number,
end of t_LINE1,
BEGIN OF t_line1,
carrid TYPE string,
connid TYPE string,
fldate TYPE d,
price TYPE t_number,
END OF t_line1,
tt_LINE1 type standard table of t_LINE1 with default key,
tt_line1 TYPE STANDARD TABLE OF t_line1 WITH DEFAULT KEY,
begin of t_TABLE2,
CARRID type string,
PRICE type t_number,
LINE1 type tt_LINE1,
end of t_TABLE2,
BEGIN OF t_table2,
carrid TYPE string,
price TYPE t_number,
line1 TYPE tt_line1,
END OF t_table2,
tt_TABLE2 type standard table of t_TABLE2 with default key,
tt_table2 TYPE STANDARD TABLE OF t_table2 WITH DEFAULT KEY,
begin of t_Sheet1,
DATE type d,
TIME type t,
USER type string,
TOTAL type t_number,
PRICE type t_number,
TABLE1 type tt_TABLE1,
TABLE2 type tt_TABLE2,
end of t_Sheet1,
BEGIN OF t_sheet1,
date TYPE d,
time TYPE t,
user TYPE string,
total TYPE t_number,
price TYPE t_number,
table1 TYPE tt_table1,
table2 TYPE tt_table2,
END OF t_sheet1,
begin of t_TABLE3,
PERSON type string,
SALARY type t_number,
end of t_TABLE3,
BEGIN OF t_table3,
person TYPE string,
salary TYPE t_number,
END OF t_table3,
tt_TABLE3 type standard table of t_TABLE3 with default key,
tt_table3 TYPE STANDARD TABLE OF t_table3 WITH DEFAULT KEY,
begin of t_Sheet2,
DATE type d,
TIME type t,
USER type string,
TOTAL type t_number,
TABLE3 type tt_TABLE3,
end of t_Sheet2.
BEGIN OF t_sheet2,
date TYPE d,
time TYPE t,
user TYPE string,
total TYPE t_number,
table3 TYPE tt_table3,
END OF t_sheet2.
DATA: lo_data type ref to ZCL_EXCEL_TEMPLATE_DATA.
DATA: lo_data TYPE REF TO zcl_excel_template_data.
*=================
* End of generated code
*=================

View File

@ -147,8 +147,8 @@ CLASS zcl_excel DEFINITION
IMPORTING
!io_theme TYPE REF TO zcl_excel_theme .
METHODS fill_template
importing
!iv_data TYPE REF TO ZCL_EXCEL_TEMPLATE_DATA
IMPORTING
!iv_data TYPE REF TO zcl_excel_template_data
RAISING
zcx_excel .
PROTECTED SECTION.

View File

@ -37,7 +37,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_COLLECTION IMPLEMENTATION.
CLASS zcl_excel_collection IMPLEMENTATION.
METHOD add .

View File

@ -15,7 +15,7 @@ CLASS zcl_excel_collection_iterator DEFINITION
VALUE(object) TYPE REF TO object.
METHODS constructor
IMPORTING
collection TYPE REF TO zCL_excel_COLLECTION.
collection TYPE REF TO zcl_excel_collection.
PROTECTED SECTION.
PRIVATE SECTION.
DATA index TYPE i VALUE 0.
@ -24,7 +24,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_COLLECTION_ITERATOR IMPLEMENTATION.
CLASS zcl_excel_collection_iterator IMPLEMENTATION.
METHOD constructor .

View File

@ -221,7 +221,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_COMMON IMPLEMENTATION.
CLASS zcl_excel_common IMPLEMENTATION.
METHOD calculate_cell_distance.

View File

@ -1405,7 +1405,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_sheet_nodigit.
" Sheet name not ending with digit
" Sheet name not ending with digit
macro_shift_formula(
iv_reference_formula = 'Sheet!A1'
iv_shift_cols = 1
@ -1416,7 +1416,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_sheet_nodig.
" Sheet name ending with digit
" Sheet name ending with digit
macro_shift_formula(
iv_reference_formula = 'Sheet2!A1'
iv_shift_cols = 1
@ -1427,7 +1427,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_sheet_special.
" Sheet name with special characters
" Sheet name with special characters
macro_shift_formula(
iv_reference_formula = |'Sheet name'!A1|
iv_shift_cols = 1
@ -1438,7 +1438,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_resp_blanks_1.
" Respecting blanks
" Respecting blanks
macro_shift_formula(
iv_reference_formula = 'SUBTOTAL(109,Table1[SUM 1])'
iv_shift_cols = 1
@ -1449,7 +1449,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_resp_blanks_2.
" Respecting blanks
" Respecting blanks
macro_shift_formula(
iv_reference_formula = 'B4 & C4'
iv_shift_cols = 0
@ -1460,7 +1460,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_range.
" F_1 is a range name, not a cell address
" F_1 is a range name, not a cell address
macro_shift_formula(
iv_reference_formula = 'SUM(F_1,F_2)'
iv_shift_cols = 1
@ -1470,7 +1470,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
ENDMETHOD.
METHOD shift_formula_notcols.
" RC are not columns
" RC are not columns
macro_shift_formula(
iv_reference_formula = 'INDIRECT("RC[4]",FALSE)'
iv_shift_cols = 1
@ -1481,7 +1481,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_name.
" A1 is a sheet name
" A1 is a sheet name
macro_shift_formula(
iv_reference_formula = |'A1'!$A$1|
iv_shift_cols = 1
@ -1492,7 +1492,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_refcolumn1.
" Reference to another column in the same row of a Table, with a space in the column name
" Reference to another column in the same row of a Table, with a space in the column name
macro_shift_formula(
iv_reference_formula = 'Tbl[[#This Row],[Air fare]]'
iv_shift_cols = 1
@ -1503,7 +1503,7 @@ CLASS lcl_excel_common_test IMPLEMENTATION.
METHOD shift_formula_refcolumn2.
" Reference to another column in the same row of a Table, inside more complex expression
" Reference to another column in the same row of a Table, inside more complex expression
macro_shift_formula(
iv_reference_formula = 'Tbl[[#This Row],[Air]]+A1'
iv_shift_cols = 1

View File

@ -255,7 +255,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_CONVERTER IMPLEMENTATION.
CLASS zcl_excel_converter IMPLEMENTATION.
METHOD ask_option.

View File

@ -46,7 +46,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_FONT IMPLEMENTATION.
CLASS zcl_excel_font IMPLEMENTATION.
METHOD calculate_text_width.

View File

@ -1,11 +1,11 @@
CLASS ltcl_Test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
PRIVATE SECTION.
METHODS calculate FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_Test IMPLEMENTATION.
CLASS ltcl_test IMPLEMENTATION.
METHOD calculate.

View File

@ -876,7 +876,7 @@ CLASS zcl_excel_reader_2007 IMPLEMENTATION.
lo_node_si TYPE REF TO if_ixml_element,
lo_node_si_child TYPE REF TO if_ixml_element,
lo_node_r_child_t TYPE REF TO if_ixml_element,
lo_node_r_child_rPr TYPE REF TO if_ixml_element,
lo_node_r_child_rpr TYPE REF TO if_ixml_element,
lo_font TYPE REF TO zcl_excel_style_font,
ls_rtf TYPE zexcel_s_rtf,
lv_current_offset TYPE int2,

View File

@ -1,133 +1,133 @@
*"* use this source file for your ABAP unit test classes
class lcl_test definition deferred.
class zcl_excel_reader_huge_file definition local friends lcl_test.
CLASS lcl_test DEFINITION DEFERRED.
CLASS zcl_excel_reader_huge_file DEFINITION LOCAL FRIENDS lcl_test.
*
class lcl_test definition for testing
risk level harmless
duration short.
CLASS lcl_test DEFINITION FOR TESTING
RISK LEVEL HARMLESS
DURATION SHORT.
private section.
data:
out type ref to zcl_excel_reader_huge_file, " object under test
excel type ref to zcl_excel,
worksheet type ref to zcl_excel_worksheet.
methods:
setup raising cx_static_check,
test_number for testing raising cx_static_check,
test_shared_string for testing raising cx_static_check,
test_shared_string_missing for testing raising cx_static_check,
test_inline_string for testing raising cx_static_check,
test_empty_cells for testing raising cx_static_check,
test_boolean for testing raising cx_static_check,
test_style for testing raising cx_static_check,
test_style_missing for testing raising cx_static_check,
test_formula for testing raising cx_static_check,
test_read_shared_strings for testing raising cx_static_check,
test_shared_string_some_empty for testing raising cx_static_check,
test_skip_to_inexistent for testing raising cx_static_check,
get_reader importing iv_xml type string returning value(eo_reader) type ref to if_sxml_reader,
assert_value_equals importing iv_row type i default 1 iv_col type i default 1 iv_value type string,
assert_formula_equals importing iv_row type i default 1 iv_col type i default 1 iv_formula type string,
assert_style_equals importing iv_row type i default 1 iv_col type i default 1 iv_style type ZEXCEL_CELL_STYLE,
assert_datatype_equals importing iv_row type i default 1 iv_col type i default 1 iv_datatype type string.
PRIVATE SECTION.
DATA:
out TYPE REF TO zcl_excel_reader_huge_file, " object under test
excel TYPE REF TO zcl_excel,
worksheet TYPE REF TO zcl_excel_worksheet.
METHODS:
setup RAISING cx_static_check,
test_number FOR TESTING RAISING cx_static_check,
test_shared_string FOR TESTING RAISING cx_static_check,
test_shared_string_missing FOR TESTING RAISING cx_static_check,
test_inline_string FOR TESTING RAISING cx_static_check,
test_empty_cells FOR TESTING RAISING cx_static_check,
test_boolean FOR TESTING RAISING cx_static_check,
test_style FOR TESTING RAISING cx_static_check,
test_style_missing FOR TESTING RAISING cx_static_check,
test_formula FOR TESTING RAISING cx_static_check,
test_read_shared_strings FOR TESTING RAISING cx_static_check,
test_shared_string_some_empty FOR TESTING RAISING cx_static_check,
test_skip_to_inexistent FOR TESTING RAISING cx_static_check,
get_reader IMPORTING iv_xml TYPE string RETURNING VALUE(eo_reader) TYPE REF TO if_sxml_reader,
assert_value_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_value TYPE string,
assert_formula_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_formula TYPE string,
assert_style_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_style TYPE zexcel_cell_style,
assert_datatype_equals IMPORTING iv_row TYPE i DEFAULT 1 iv_col TYPE i DEFAULT 1 iv_datatype TYPE string.
endclass. "lcl_test DEFINITION
ENDCLASS. "lcl_test DEFINITION
*
class lcl_test implementation.
CLASS lcl_test IMPLEMENTATION.
*
method test_number.
data lo_reader type ref to if_sxml_reader.
METHOD test_number.
DATA lo_reader TYPE REF TO if_sxml_reader.
lo_reader = get_reader(
`<c r="A1" t="n"><v>17</v></c>`
).
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
assert_value_equals( `17` ).
assert_datatype_equals( `n` ).
endmethod. "test_shared_string
ENDMETHOD. "test_shared_string
*
method test_shared_string.
data lo_reader type ref to if_sxml_reader.
data: ls_shared_string type zcl_excel_reader_huge_file=>t_shared_string.
METHOD test_shared_string.
DATA lo_reader TYPE REF TO if_sxml_reader.
DATA: ls_shared_string TYPE zcl_excel_reader_huge_file=>t_shared_string.
ls_shared_string-value = `Test1`.
append ls_shared_string to out->shared_strings.
APPEND ls_shared_string TO out->shared_strings.
ls_shared_string-value = `Test2`.
append ls_shared_string to out->shared_strings.
APPEND ls_shared_string TO out->shared_strings.
lo_reader = get_reader(
`<c r="A1" t="s"><v>1</v></c>`
).
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
assert_value_equals( `Test2` ).
assert_datatype_equals( `s` ).
endmethod. "test_shared_string
ENDMETHOD. "test_shared_string
*
method test_shared_string_missing.
METHOD test_shared_string_missing.
data: lo_reader type ref to if_sxml_reader,
lo_ex type ref to lcx_not_found,
lv_text type string.
data: ls_shared_string type zcl_excel_reader_huge_file=>t_shared_string.
DATA: lo_reader TYPE REF TO if_sxml_reader,
lo_ex TYPE REF TO lcx_not_found,
lv_text TYPE string.
DATA: ls_shared_string TYPE zcl_excel_reader_huge_file=>t_shared_string.
ls_shared_string-value = `Test`.
append ls_shared_string to out->shared_strings.
APPEND ls_shared_string TO out->shared_strings.
lo_reader = get_reader(
`<c r="A1" t="s"><v>1</v></c>`
).
try.
TRY.
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
CL_ABAP_UNIT_ASSERT=>fail( `Index to non-existent shared string should give an error` ).
catch lcx_not_found into lo_ex.
cl_abap_unit_assert=>fail( `Index to non-existent shared string should give an error` ).
CATCH lcx_not_found INTO lo_ex.
lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger
endtry.
ENDTRY.
endmethod.
ENDMETHOD.
*
method test_inline_string.
data lo_reader type ref to if_sxml_reader.
METHOD test_inline_string.
DATA lo_reader TYPE REF TO if_sxml_reader.
lo_reader = get_reader(
`<c r="A1" t="inlineStr"><is><t>Alpha</t></is></c>`
).
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
assert_value_equals( `Alpha` ).
assert_datatype_equals( `inlineStr` ).
endmethod. "test_inline_string
ENDMETHOD. "test_inline_string
*
method test_boolean.
data lo_reader type ref to if_sxml_reader.
METHOD test_boolean.
DATA lo_reader TYPE REF TO if_sxml_reader.
lo_reader = get_reader(
`<c r="A1" t="b"><v>1</v></c>`
).
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
assert_value_equals( `1` ).
assert_datatype_equals( `b` ).
endmethod. "test_boolean
ENDMETHOD. "test_boolean
*
method test_formula.
data lo_reader type ref to if_sxml_reader.
METHOD test_formula.
DATA lo_reader TYPE REF TO if_sxml_reader.
lo_reader = get_reader(
`<c r="A1" t="n"><f>A2*A2</f></c>`
).
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
assert_formula_equals( `A2*A2` ).
assert_datatype_equals( `n` ).
endmethod. "test_formula
ENDMETHOD. "test_formula
*
method test_empty_cells.
METHOD test_empty_cells.
* There is no need to store an empty cell in the ABAP worksheet structure
data: lo_reader type ref to if_sxml_reader.
data: ls_shared_string type zcl_excel_reader_huge_file=>t_shared_string.
DATA: lo_reader TYPE REF TO if_sxml_reader.
DATA: ls_shared_string TYPE zcl_excel_reader_huge_file=>t_shared_string.
ls_shared_string-value = ``.
append ls_shared_string to out->shared_strings.
APPEND ls_shared_string TO out->shared_strings.
ls_shared_string-value = `t`.
append ls_shared_string to out->shared_strings.
APPEND ls_shared_string TO out->shared_strings.
lo_reader = get_reader(
`<c r="A1" t="s"><v>0</v></c>` &
`<c r="A2" t="inlineStr"><is><t></t></is></c>` &
@ -140,16 +140,16 @@ class lcl_test implementation.
assert_value_equals( iv_row = 2 iv_col = 1 iv_value = `` ).
assert_value_equals( iv_row = 3 iv_col = 1 iv_value = `t` ).
endmethod.
ENDMETHOD.
*
method test_style.
data:
lo_reader type ref to if_sxml_reader,
lo_style type ref to zcl_excel_style,
lv_guid type ZEXCEL_CELL_STYLE.
create object lo_style.
append lo_style to out->styles.
METHOD test_style.
DATA:
lo_reader TYPE REF TO if_sxml_reader,
lo_style TYPE REF TO zcl_excel_style,
lv_guid TYPE zexcel_cell_style.
CREATE OBJECT lo_style.
APPEND lo_style TO out->styles.
lv_guid = lo_style->get_guid( ).
lo_reader = get_reader(
@ -159,173 +159,173 @@ class lcl_test implementation.
assert_style_equals( lv_guid ).
endmethod. "test_style
ENDMETHOD. "test_style
*
method test_style_missing.
METHOD test_style_missing.
data:
lo_reader type ref to if_sxml_reader,
lo_ex type ref to lcx_not_found,
lv_text type string.
DATA:
lo_reader TYPE REF TO if_sxml_reader,
lo_ex TYPE REF TO lcx_not_found,
lv_text TYPE string.
lo_reader = get_reader(
`<c r="A1" s="0"><v>18</v></c>`
).
try.
TRY.
out->read_worksheet_data( io_reader = lo_reader io_worksheet = worksheet ).
CL_ABAP_UNIT_ASSERT=>fail( `Reference to non-existent style should throw an lcx_not_found exception` ).
catch lcx_not_found into lo_ex.
cl_abap_unit_assert=>fail( `Reference to non-existent style should throw an lcx_not_found exception` ).
CATCH lcx_not_found INTO lo_ex.
lv_text = lo_ex->get_text( ). " >>> May inspect the message in the debugger
endtry.
ENDTRY.
endmethod. "test_style
ENDMETHOD. "test_style
*
method test_read_shared_strings.
data: lo_c2x type ref to cl_abap_conv_out_ce,
lv_xstring type xstring,
lo_reader type ref to if_sxml_reader,
lt_act type stringtab,
lt_exp type stringtab.
METHOD test_read_shared_strings.
DATA: lo_c2x TYPE REF TO cl_abap_conv_out_ce,
lv_xstring TYPE xstring,
lo_reader TYPE REF TO if_sxml_reader,
lt_act TYPE stringtab,
lt_exp TYPE stringtab.
lo_c2x = cl_abap_conv_out_ce=>create( ).
lo_c2x->convert( exporting data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>`
importing buffer = lv_xstring ).
lo_c2x->convert( EXPORTING data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>`
IMPORTING buffer = lv_xstring ).
lo_reader = cl_sxml_string_reader=>create( lv_xstring ).
append :
`` to lt_exp,
`Alpha` to lt_exp,
`Bravo` to lt_exp.
APPEND :
`` TO lt_exp,
`Alpha` TO lt_exp,
`Bravo` TO lt_exp.
lt_act = out->read_shared_strings( lo_reader ).
CL_ABAP_UNIT_ASSERT=>assert_equals( act = lt_act
cl_abap_unit_assert=>assert_equals( act = lt_act
exp = lt_exp ).
endmethod.
ENDMETHOD.
*
method test_shared_string_some_empty.
data: lo_reader type ref to if_sxml_reader,
lt_act type stringtab,
lt_exp type stringtab.
METHOD test_shared_string_some_empty.
DATA: lo_reader TYPE REF TO if_sxml_reader,
lt_act TYPE stringtab,
lt_exp TYPE stringtab.
lo_reader = cl_sxml_string_reader=>create( cl_abap_codepage=>convert_to(
`<sst><si><t/></si>` &
`<si><t>Alpha</t></si>` &
`<si><t/></si>` &
`<si><t>Bravo</t></si></sst>`
) ).
append :
`` to lt_exp,
`Alpha` to lt_exp,
`` to lt_exp,
`Bravo` to lt_exp.
APPEND :
`` TO lt_exp,
`Alpha` TO lt_exp,
`` TO lt_exp,
`Bravo` TO lt_exp.
lt_act = out->read_shared_strings( lo_reader ).
CL_ABAP_UNIT_ASSERT=>assert_equals( act = lt_act
cl_abap_unit_assert=>assert_equals( act = lt_act
exp = lt_exp ).
endmethod.
ENDMETHOD.
*
method test_skip_to_inexistent.
data: lo_c2x type ref to cl_abap_conv_out_ce,
lv_xstring type xstring,
lo_reader type ref to if_sxml_reader,
lo_ex type ref to lcx_not_found,
lv_text type string.
METHOD test_skip_to_inexistent.
DATA: lo_c2x TYPE REF TO cl_abap_conv_out_ce,
lv_xstring TYPE xstring,
lo_reader TYPE REF TO if_sxml_reader,
lo_ex TYPE REF TO lcx_not_found,
lv_text TYPE string.
lo_c2x = cl_abap_conv_out_ce=>create( ).
lo_c2x->convert( exporting data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>`
importing buffer = lv_xstring ).
lo_c2x->convert( EXPORTING data = `<sst><si><t/></si><si><t>Alpha</t></si><si><t>Bravo</t></si></sst>`
IMPORTING buffer = lv_xstring ).
lo_reader = cl_sxml_string_reader=>create( lv_xstring ).
try.
TRY.
out->skip_to( iv_element_name = `nonExistingElement` io_reader = lo_reader ).
CL_ABAP_UNIT_ASSERT=>fail( `Skipping to non-existing element must raise lcx_not_found exception` ).
catch lcx_not_found into lo_ex.
cl_abap_unit_assert=>fail( `Skipping to non-existing element must raise lcx_not_found exception` ).
CATCH lcx_not_found INTO lo_ex.
lv_text = lo_ex->get_text( ). " May inspect exception text in debugger
endtry.
endmethod.
ENDTRY.
ENDMETHOD.
*
method get_reader.
data: lv_full type string,
lo_c2x type ref to cl_abap_conv_out_ce,
lv_xstring type xstring.
concatenate `<root><sheetData><row>` iv_xml `</row></sheetData></root>` into lv_full.
METHOD get_reader.
DATA: lv_full TYPE string,
lo_c2x TYPE REF TO cl_abap_conv_out_ce,
lv_xstring TYPE xstring.
CONCATENATE `<root><sheetData><row>` iv_xml `</row></sheetData></root>` INTO lv_full.
lo_c2x = cl_abap_conv_out_ce=>create( ).
lo_c2x->convert( exporting data = lv_full
importing buffer = lv_xstring ).
lo_c2x->convert( EXPORTING data = lv_full
IMPORTING buffer = lv_xstring ).
eo_reader = cl_sxml_string_reader=>create( lv_xstring ).
endmethod. "get_reader
ENDMETHOD. "get_reader
*
method assert_value_equals.
METHOD assert_value_equals.
constants: lc_empty_string type string value is initial.
CONSTANTS: lc_empty_string TYPE string VALUE IS INITIAL.
field-symbols: <ls_cell_data> type zexcel_s_cell_data,
<lv_value> type string.
FIELD-SYMBOLS: <ls_cell_data> TYPE zexcel_s_cell_data,
<lv_value> TYPE string.
read table worksheet->sheet_content assigning <ls_cell_data>
with table key cell_row = iv_row cell_column = iv_col.
if sy-subrc eq 0.
assign <ls_cell_data>-cell_value to <lv_value>.
else.
assign lc_empty_string to <lv_value>.
endif.
READ TABLE worksheet->sheet_content ASSIGNING <ls_cell_data>
WITH TABLE KEY cell_row = iv_row cell_column = iv_col.
IF sy-subrc EQ 0.
ASSIGN <ls_cell_data>-cell_value TO <lv_value>.
ELSE.
ASSIGN lc_empty_string TO <lv_value>.
ENDIF.
CL_ABAP_UNIT_ASSERT=>assert_equals( act = <lv_value>
cl_abap_unit_assert=>assert_equals( act = <lv_value>
exp = iv_value ).
endmethod. "assert_value_equals
ENDMETHOD. "assert_value_equals
**
method assert_formula_equals.
METHOD assert_formula_equals.
field-symbols: <ls_cell_data> type zexcel_s_cell_data.
FIELD-SYMBOLS: <ls_cell_data> TYPE zexcel_s_cell_data.
read table worksheet->sheet_content assigning <ls_cell_data>
with table key cell_row = iv_row cell_column = iv_col.
CL_ABAP_UNIT_ASSERT=>assert_subrc( sy-subrc ).
READ TABLE worksheet->sheet_content ASSIGNING <ls_cell_data>
WITH TABLE KEY cell_row = iv_row cell_column = iv_col.
cl_abap_unit_assert=>assert_subrc( sy-subrc ).
CL_ABAP_UNIT_ASSERT=>assert_equals( act = <ls_cell_data>-cell_formula
cl_abap_unit_assert=>assert_equals( act = <ls_cell_data>-cell_formula
exp = iv_formula ).
endmethod. "assert_formula_equals
ENDMETHOD. "assert_formula_equals
*
method assert_style_equals.
METHOD assert_style_equals.
field-symbols: <ls_cell_data> type zexcel_s_cell_data.
FIELD-SYMBOLS: <ls_cell_data> TYPE zexcel_s_cell_data.
read table worksheet->sheet_content assigning <ls_cell_data>
with table key cell_row = iv_row cell_column = iv_col.
CL_ABAP_UNIT_ASSERT=>assert_subrc( sy-subrc ).
READ TABLE worksheet->sheet_content ASSIGNING <ls_cell_data>
WITH TABLE KEY cell_row = iv_row cell_column = iv_col.
cl_abap_unit_assert=>assert_subrc( sy-subrc ).
CL_ABAP_UNIT_ASSERT=>assert_equals( act = <ls_cell_data>-cell_style
cl_abap_unit_assert=>assert_equals( act = <ls_cell_data>-cell_style
exp = iv_style ).
endmethod.
ENDMETHOD.
*
method assert_datatype_equals.
METHOD assert_datatype_equals.
field-symbols: <ls_cell_data> type zexcel_s_cell_data.
FIELD-SYMBOLS: <ls_cell_data> TYPE zexcel_s_cell_data.
read table worksheet->sheet_content assigning <ls_cell_data>
with table key cell_row = iv_row cell_column = iv_col.
CL_ABAP_UNIT_ASSERT=>assert_subrc( sy-subrc ).
READ TABLE worksheet->sheet_content ASSIGNING <ls_cell_data>
WITH TABLE KEY cell_row = iv_row cell_column = iv_col.
cl_abap_unit_assert=>assert_subrc( sy-subrc ).
CL_ABAP_UNIT_ASSERT=>assert_equals( act = <ls_cell_data>-data_type
cl_abap_unit_assert=>assert_equals( act = <ls_cell_data>-data_type
exp = iv_datatype ).
endmethod. "assert_datatype_equals
method setup.
create object out.
create object excel.
create object worksheet
exporting
ENDMETHOD. "assert_datatype_equals
METHOD setup.
CREATE OBJECT out.
CREATE OBJECT excel.
CREATE OBJECT worksheet
EXPORTING
ip_excel = excel.
endmethod. "setup
endclass. "lcl_test IMPLEMENTATION
ENDMETHOD. "setup
ENDCLASS. "lcl_test IMPLEMENTATION

View File

@ -725,7 +725,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
CLASS zcl_excel_worksheet IMPLEMENTATION.
METHOD add_comment.

View File

@ -3846,7 +3846,7 @@ CLASS zcl_excel_writer_2007 IMPLEMENTATION.
lc_xml_attr_priority TYPE string VALUE 'priority',
lc_xml_attr_operator TYPE string VALUE 'operator',
lc_xml_attr_text TYPE string VALUE 'text',
lc_xml_attr_notContainsText TYPE string VALUE 'notContainsText',
lc_xml_attr_notcontainstext TYPE string VALUE 'notContainsText',
lc_xml_attr_allowblank TYPE string VALUE 'allowBlank',
lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage',
lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage',

View File

@ -53,7 +53,7 @@ ENDCLASS.
CLASS ZCL_EXCEL_WRITER_CSV IMPLEMENTATION.
CLASS zcl_excel_writer_csv IMPLEMENTATION.
METHOD create.

View File

@ -69,7 +69,7 @@ CLASS zcl_excel_writer_huge_file IMPLEMENTATION.
**********************************************************************
* STEP 0: Build Regex for invalid characters
" uccpi returns 2 chars but for this specific input 1 char is enough
" uccpi returns 2 chars but for this specific input 1 char is enough
CASE cl_abap_char_utilities=>charsize.
WHEN 1.lv_last_allowed_char = cl_abap_conv_in_ce=>uccpi( 255 ). " FF in non-Unicode
WHEN 2.lv_last_allowed_char = cl_abap_conv_in_ce=>uccpi( 65533 )." FFFD in Unicode