huge reader reading cells multiple styles (#897)

* huge reader reading cells multiple styles

Fix #614

Co-authored-by: sandraros <sandra.rossi@gmail.com>
Co-authored-by: Abo <andrea@borgia.bo.it>
This commit is contained in:
sandraros 2021-11-29 14:40:22 +01:00 committed by GitHub
parent d7011f715c
commit 3167c6a8f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 10 deletions

View File

@ -249,16 +249,20 @@ CLASS zcl_excel_reader_huge_file IMPLEMENTATION.
WHILE io_reader->node_type NE c_end_of_stream.
io_reader->next_node( ).
IF io_reader->name EQ `t`.
CASE io_reader->node_type .
WHEN c_element_open .
CLEAR lv_value .
WHEN c_node_value .
lv_value = lv_value && io_reader->value .
WHEN c_element_close .
APPEND lv_value TO et_shared_strings.
ENDCASE .
ENDIF.
CASE io_reader->name.
WHEN 'si'.
CASE io_reader->node_type .
WHEN c_element_open .
CLEAR lv_value .
WHEN c_element_close .
APPEND lv_value TO et_shared_strings.
ENDCASE .
WHEN 't'.
CASE io_reader->node_type .
WHEN c_node_value .
lv_value = lv_value && io_reader->value .
ENDCASE .
ENDCASE .
ENDWHILE.
ENDMETHOD.

View File

@ -25,6 +25,7 @@ CLASS lcl_test DEFINITION FOR TESTING
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_shared_string_multi_style 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,
@ -230,6 +231,29 @@ CLASS lcl_test IMPLEMENTATION.
ENDMETHOD.
*
METHOD test_shared_string_multi_style.
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>Cell A2</t></si>` &&
`<si><r><t>the following coloured part</t></r><r><rPr><sz val="11"/><color rgb="FFFF0000"/><rFont val="Calibri"/><family val="2"/><scheme val="minor"/></rPr><t xml:space="preserve"> will be preserved</t></r></si>` &&
`<si><t>Cell A3</t></si>` &&
`</sst>` ) ).
APPEND :
`Cell A2` TO lt_exp,
`the following coloured part will be preserved` TO lt_exp,
`Cell A3` TO lt_exp.
lt_act = out->read_shared_strings( lo_reader ).
cl_abap_unit_assert=>assert_equals( act = lt_act
exp = lt_exp ).
ENDMETHOD.
*
METHOD test_skip_to_inexistent.