mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 13:46:17 +08:00
ip_style TYPE any + add_new_style( io_clone_of = ) (#929)
* ip_style TYPE any + add_new_style( io_clone_of = ) * zdemo_excel2 instead of zdemo_excel1 * Update zcl_excel_worksheet.clas.abap * Unit tests added + fix demo 2 Co-authored-by: sandraros <sandra.rossi@gmail.com> Co-authored-by: Abo <andrea@borgia.bo.it>
This commit is contained in:
parent
8f630081ed
commit
7fa137bc94
|
@ -13,32 +13,26 @@ DATA: lo_excel TYPE REF TO zcl_excel,
|
|||
lo_style_bold TYPE REF TO zcl_excel_style,
|
||||
lo_style_underline TYPE REF TO zcl_excel_style,
|
||||
lo_style_filled TYPE REF TO zcl_excel_style,
|
||||
lo_style_filled_green TYPE REF TO zcl_excel_style,
|
||||
lo_style_filled_turquoise TYPE REF TO zcl_excel_style,
|
||||
lo_style_border TYPE REF TO zcl_excel_style,
|
||||
lo_style_button TYPE REF TO zcl_excel_style,
|
||||
lo_border_dark TYPE REF TO zcl_excel_style_border,
|
||||
lo_border_light TYPE REF TO zcl_excel_style_border.
|
||||
|
||||
DATA: lv_style_bold_guid TYPE zexcel_cell_style,
|
||||
lv_style_underline_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_green_guid TYPE zexcel_cell_style,
|
||||
lv_style_border_guid TYPE zexcel_cell_style,
|
||||
lv_style_button_guid TYPE zexcel_cell_style,
|
||||
lv_style_filled_turquoise_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerlb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerlt_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerrb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_cornerrt_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontal90_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontal270_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_horizontalb_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_vertical_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_vertical2_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_fromcenter_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal45_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal45b_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal135_guid TYPE zexcel_cell_style,
|
||||
lv_style_gr_diagonal135b_guid TYPE zexcel_cell_style.
|
||||
lo_border_light TYPE REF TO zcl_excel_style_border,
|
||||
lo_style_gr_cornerlb TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_cornerlt TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_cornerrb TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_cornerrt TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_horizontal90 TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_horizontal270 TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_horizontalb TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_vertical TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_vertical2 TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_fromcenter TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_diagonal45 TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_diagonal45b TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_diagonal135 TYPE REF TO zcl_excel_style,
|
||||
lo_style_gr_diagonal135b TYPE REF TO zcl_excel_style.
|
||||
|
||||
DATA: lv_file TYPE xstring,
|
||||
lv_bytecount TYPE i,
|
||||
|
@ -74,7 +68,6 @@ START-OF-SELECTION.
|
|||
lo_style_bold->font->name = zcl_excel_style_font=>c_name_arial.
|
||||
lo_style_bold->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_bold->font->color-rgb = zcl_excel_style_color=>c_red.
|
||||
lv_style_bold_guid = lo_style_bold->get_guid( ).
|
||||
" Create an underline double style
|
||||
lo_style_underline = lo_excel->add_new_style( ).
|
||||
lo_style_underline->font->underline = abap_true.
|
||||
|
@ -82,225 +75,148 @@ START-OF-SELECTION.
|
|||
lo_style_underline->font->name = zcl_excel_style_font=>c_name_roman.
|
||||
lo_style_underline->font->scheme = zcl_excel_style_font=>c_scheme_none.
|
||||
lo_style_underline->font->family = zcl_excel_style_font=>c_family_roman.
|
||||
lv_style_underline_guid = lo_style_underline->get_guid( ).
|
||||
" Create filled style yellow
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-theme = zcl_excel_style_color=>c_theme_accent6.
|
||||
lv_style_filled_guid = lo_style_filled->get_guid( ).
|
||||
" Create border with button effects
|
||||
lo_style_button = lo_excel->add_new_style( ).
|
||||
lo_style_button->borders->right = lo_border_dark.
|
||||
lo_style_button->borders->down = lo_border_dark.
|
||||
lo_style_button->borders->left = lo_border_light.
|
||||
lo_style_button->borders->top = lo_border_light.
|
||||
lv_style_button_guid = lo_style_button->get_guid( ).
|
||||
"Create style with border
|
||||
lo_style_border = lo_excel->add_new_style( ).
|
||||
lo_style_border->borders->allborders = lo_border_dark.
|
||||
lo_style_border->borders->diagonal = lo_border_dark.
|
||||
lo_style_border->borders->diagonal_mode = zcl_excel_style_borders=>c_diagonal_both.
|
||||
lv_style_border_guid = lo_style_border->get_guid( ).
|
||||
" Create filled style green
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_filled_green_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_filled_green = lo_excel->add_new_style( ).
|
||||
lo_style_filled_green->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled_green->fill->fgcolor-rgb = zcl_excel_style_color=>c_green.
|
||||
lo_style_filled_green->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled_green->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
|
||||
" Create filled with gradients
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerlb_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_cornerlb = lo_excel->add_new_style( ).
|
||||
lo_style_gr_cornerlb->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlb.
|
||||
lo_style_gr_cornerlb->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_gr_cornerlb->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_gr_cornerlb->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_gr_cornerlb->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlt.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerlt_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_cornerlt = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_cornerlt->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerlt.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerrb_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_cornerrb = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_cornerrb->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrb.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrt.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_cornerrt_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_cornerrt = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_cornerrt->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_cornerrt.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal90.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontal90_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_horizontal90 = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_horizontal90->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal90.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal270.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontal270_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_horizontal270 = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_horizontal270->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontal270.
|
||||
|
||||
lo_style_gr_horizontalb = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_horizontalb->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontalb.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_horizontalb.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_horizontalb_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_vertical = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_vertical->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
|
||||
lo_style_gr_vertical2 = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_vertical2->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
lo_style_gr_vertical2->fill->fgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_gr_vertical2->fill->bgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_vertical_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_gr_fromcenter = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_fromcenter->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_fromcenter.
|
||||
|
||||
lo_style_gr_diagonal45 = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_diagonal45->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45.
|
||||
|
||||
lo_style_gr_diagonal45b = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_diagonal45b->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45b.
|
||||
|
||||
lo_style_gr_diagonal135 = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_diagonal135->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135.
|
||||
|
||||
lo_style_gr_diagonal135b = lo_excel->add_new_style( io_clone_of = lo_style_gr_cornerlb ).
|
||||
lo_style_gr_diagonal135b->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135b.
|
||||
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_vertical.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_vertical2_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_fromcenter.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_fromcenter_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal45_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal45b.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal45b_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal135_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_gradient_diagonal135b.
|
||||
lo_style_filled->fill->fgcolor-rgb = zcl_excel_style_color=>c_blue.
|
||||
lo_style_filled->fill->bgcolor-rgb = zcl_excel_style_color=>c_white.
|
||||
lo_style_filled->font->name = zcl_excel_style_font=>c_name_cambria.
|
||||
lo_style_filled->font->scheme = zcl_excel_style_font=>c_scheme_major.
|
||||
lv_style_gr_diagonal135b_guid = lo_style_filled->get_guid( ).
|
||||
|
||||
|
||||
|
||||
" Create filled style turquoise using legacy excel ver <= 2003 palette. (https://code.sdn.sap.com/spaces/abap2xlsx/tickets/92)
|
||||
lo_style_filled = lo_excel->add_new_style( ).
|
||||
" Create filled style turquoise using legacy excel ver <= 2003 palette. (https://github.com/abap2xlsx/abap2xlsx/issues/92)
|
||||
lo_style_filled_turquoise = lo_excel->add_new_style( ).
|
||||
lo_excel->legacy_palette->set_color( "replace built-in color from palette with out custom RGB turquoise
|
||||
ip_index = 16
|
||||
ip_color = '0040E0D0' ).
|
||||
|
||||
lo_style_filled->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled->fill->fgcolor-indexed = 16.
|
||||
lv_style_filled_turquoise_guid = lo_style_filled->get_guid( ).
|
||||
lo_style_filled_turquoise->fill->filltype = zcl_excel_style_fill=>c_fill_solid.
|
||||
lo_style_filled_turquoise->fill->fgcolor-indexed = 16.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Styles' ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 2 ip_value = 'Hello world' ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lv_style_bold_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lv_style_underline_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lv_style_border_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lv_style_button_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Modified color for Excel 2003' ip_style = lv_style_filled_turquoise_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 3 ip_value = 'Bold text' ip_style = lo_style_bold ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 4 ip_value = 'Underlined text' ip_style = lo_style_underline ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 5 ip_value = 'Filled text' ip_style = lo_style_filled ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 6 ip_value = 'Borders' ip_style = lo_style_border ).
|
||||
lo_worksheet->set_cell( ip_column = 'D' ip_row = 7 ip_value = 'I''m not a button :)' ip_style = lo_style_button ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 9 ip_value = 'Modified color for Excel 2003' ip_style = lo_style_filled_turquoise ).
|
||||
" Fill the cell and apply one style
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lv_style_filled_guid ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 6 ip_value = 'Filled text' ip_style = lo_style_filled ).
|
||||
" Change the style
|
||||
lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
lo_worksheet->set_cell_style( ip_column = 'B' ip_row = 6 ip_style = lo_style_filled_green ).
|
||||
" Add Style to an empty cell to test Fix for Issue
|
||||
"#44 Exception ZCX_EXCEL thrown when style is set for an empty cell
|
||||
" https://code.sdn.sap.com/spaces/abap2xlsx/tickets/44-exception-zcx_excel-thrown-when-style-is-set-for-an-empty-cell
|
||||
lo_worksheet->set_cell_style( ip_column = 'E' ip_row = 6 ip_style = lv_style_filled_green_guid ).
|
||||
" https://github.com/abap2xlsx/abap2xlsx/issues/44
|
||||
lo_worksheet->set_cell_style( ip_column = 'E' ip_row = 6 ip_style = lo_style_filled_green ).
|
||||
|
||||
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 10 ip_style = lv_style_gr_cornerlb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlb ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 10 ip_style = lo_style_gr_cornerlb ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlb ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 10 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 11 ip_style = lv_style_gr_cornerlt_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlt ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 11 ip_style = lo_style_gr_cornerlt ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerlt ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 11 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 12 ip_style = lv_style_gr_cornerrb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrb ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 12 ip_style = lo_style_gr_cornerrb ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrb ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 12 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 13 ip_style = lv_style_gr_cornerrt_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrt ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 13 ip_style = lo_style_gr_cornerrt ip_value = zcl_excel_style_fill=>c_fill_gradient_cornerrt ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 13 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 14 ip_style = lv_style_gr_horizontal90_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal90 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 14 ip_style = lo_style_gr_horizontal90 ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal90 ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 14 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 15 ip_style = lv_style_gr_horizontal270_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal270 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 15 ip_style = lo_style_gr_horizontal270 ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontal270 ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 15 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 16 ip_style = lv_style_gr_horizontalb_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontalb ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 16 ip_style = lo_style_gr_horizontalb ip_value = zcl_excel_style_fill=>c_fill_gradient_horizontalb ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 16 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 17 ip_style = lv_style_gr_vertical_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 17 ip_style = lo_style_gr_vertical ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 17 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 18 ip_style = lv_style_gr_vertical2_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 18 ip_style = lo_style_gr_vertical2 ip_value = zcl_excel_style_fill=>c_fill_gradient_vertical ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 18 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 19 ip_style = lv_style_gr_fromcenter_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_fromcenter ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 19 ip_style = lo_style_gr_fromcenter ip_value = zcl_excel_style_fill=>c_fill_gradient_fromcenter ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 19 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 20 ip_style = lv_style_gr_diagonal45_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 20 ip_style = lo_style_gr_diagonal45 ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45 ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 20 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 21 ip_style = lv_style_gr_diagonal45b_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45b ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 21 ip_style = lo_style_gr_diagonal45b ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal45b ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 21 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 22 ip_style = lv_style_gr_diagonal135_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135 ).
|
||||
lo_worksheet->set_cell( ip_column = 'B' ip_row = 22 ip_style = lo_style_gr_diagonal135 ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135 ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 22 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 23 ip_style = lv_style_gr_diagonal135b_guid ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135b ).
|
||||
lo_worksheet->set_cell( ip_column = 'C' ip_row = 23 ip_style = lo_style_gr_diagonal135b ip_value = zcl_excel_style_fill=>c_fill_gradient_diagonal135b ).
|
||||
lo_row = lo_worksheet->get_row( ip_row = 23 ).
|
||||
lo_row->set_row_height( ip_row_height = 30 ).
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ CLASS zcl_excel DEFINITION
|
|||
METHODS add_new_style
|
||||
IMPORTING
|
||||
!ip_guid TYPE zexcel_cell_style OPTIONAL
|
||||
!io_clone_of TYPE REF TO zcl_excel_style OPTIONAL
|
||||
PREFERRED PARAMETER !ip_guid
|
||||
RETURNING
|
||||
VALUE(eo_style) TYPE REF TO zcl_excel_style .
|
||||
METHODS add_new_worksheet
|
||||
|
@ -234,7 +236,8 @@ CLASS zcl_excel IMPLEMENTATION.
|
|||
* Create default style
|
||||
CREATE OBJECT eo_style
|
||||
EXPORTING
|
||||
ip_guid = ip_guid.
|
||||
ip_guid = ip_guid
|
||||
io_clone_of = io_clone_of.
|
||||
styles->add( eo_style ).
|
||||
|
||||
DATA: style2 TYPE zexcel_s_stylemapping.
|
||||
|
|
|
@ -16,7 +16,8 @@ CLASS zcl_excel_style DEFINITION
|
|||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
!ip_guid TYPE zexcel_cell_style OPTIONAL .
|
||||
!ip_guid TYPE zexcel_cell_style OPTIONAL
|
||||
!io_clone_of TYPE REF TO zcl_excel_style OPTIONAL .
|
||||
METHODS get_guid
|
||||
RETURNING
|
||||
VALUE(ep_guid) TYPE zexcel_cell_style .
|
||||
|
@ -51,6 +52,47 @@ CLASS zcl_excel_style IMPLEMENTATION.
|
|||
me->guid = zcl_excel_obsolete_func_wrap=>guid_create( ).
|
||||
ENDIF.
|
||||
|
||||
IF io_clone_of IS BOUND.
|
||||
|
||||
font->bold = io_clone_of->font->bold.
|
||||
font->color = io_clone_of->font->color.
|
||||
font->family = io_clone_of->font->family.
|
||||
font->italic = io_clone_of->font->italic.
|
||||
font->name = io_clone_of->font->name.
|
||||
font->scheme = io_clone_of->font->scheme.
|
||||
font->size = io_clone_of->font->size.
|
||||
font->strikethrough = io_clone_of->font->strikethrough.
|
||||
font->underline = io_clone_of->font->underline.
|
||||
font->underline_mode = io_clone_of->font->underline_mode.
|
||||
|
||||
fill->gradtype = io_clone_of->fill->gradtype.
|
||||
fill->filltype = io_clone_of->fill->filltype.
|
||||
fill->rotation = io_clone_of->fill->rotation.
|
||||
fill->fgcolor = io_clone_of->fill->fgcolor.
|
||||
fill->bgcolor = io_clone_of->fill->bgcolor.
|
||||
|
||||
borders->allborders = io_clone_of->borders->allborders.
|
||||
borders->diagonal = io_clone_of->borders->diagonal.
|
||||
borders->diagonal_mode = io_clone_of->borders->diagonal_mode.
|
||||
borders->down = io_clone_of->borders->down.
|
||||
borders->left = io_clone_of->borders->left.
|
||||
borders->right = io_clone_of->borders->right.
|
||||
borders->top = io_clone_of->borders->top.
|
||||
|
||||
alignment->horizontal = io_clone_of->alignment->horizontal.
|
||||
alignment->vertical = io_clone_of->alignment->vertical.
|
||||
alignment->textrotation = io_clone_of->alignment->textrotation.
|
||||
alignment->wraptext = io_clone_of->alignment->wraptext.
|
||||
alignment->shrinktofit = io_clone_of->alignment->shrinktofit.
|
||||
alignment->indent = io_clone_of->alignment->indent.
|
||||
|
||||
number_format->format_code = io_clone_of->number_format->format_code.
|
||||
|
||||
protection->hidden = io_clone_of->protection->hidden.
|
||||
protection->locked = io_clone_of->protection->locked.
|
||||
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
|
|
@ -356,10 +356,14 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
zcx_excel .
|
||||
METHODS get_columns
|
||||
RETURNING
|
||||
VALUE(eo_columns) TYPE REF TO zcl_excel_columns .
|
||||
VALUE(eo_columns) TYPE REF TO zcl_excel_columns
|
||||
RAISING
|
||||
zcx_excel .
|
||||
METHODS get_columns_iterator
|
||||
RETURNING
|
||||
VALUE(eo_iterator) TYPE REF TO zcl_excel_collection_iterator .
|
||||
VALUE(eo_iterator) TYPE REF TO zcl_excel_collection_iterator
|
||||
RAISING
|
||||
zcx_excel .
|
||||
METHODS get_style_cond_iterator
|
||||
RETURNING
|
||||
VALUE(eo_iterator) TYPE REF TO zcl_excel_collection_iterator .
|
||||
|
@ -491,7 +495,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_row TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_value TYPE simple OPTIONAL
|
||||
!ip_formula TYPE zexcel_cell_formula OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style OPTIONAL
|
||||
!ip_style TYPE any OPTIONAL
|
||||
!ip_hyperlink TYPE REF TO zcl_excel_hyperlink OPTIONAL
|
||||
!ip_data_type TYPE zexcel_cell_data_type OPTIONAL
|
||||
!ip_abap_type TYPE abap_typekind OPTIONAL
|
||||
|
@ -512,7 +516,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_columnrow TYPE csequence OPTIONAL
|
||||
!ip_column TYPE simple OPTIONAL
|
||||
!ip_row TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style
|
||||
!ip_style TYPE any
|
||||
RAISING
|
||||
zcx_excel .
|
||||
METHODS set_column_width
|
||||
|
@ -537,7 +541,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_column_end TYPE simple OPTIONAL
|
||||
!ip_row TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_row_to TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style OPTIONAL "added parameter
|
||||
!ip_style TYPE any OPTIONAL
|
||||
!ip_value TYPE simple OPTIONAL "added parameter
|
||||
!ip_formula TYPE zexcel_cell_formula OPTIONAL "added parameter
|
||||
RAISING
|
||||
|
@ -570,8 +574,8 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
METHODS set_table
|
||||
IMPORTING
|
||||
!ip_table TYPE STANDARD TABLE
|
||||
!ip_hdr_style TYPE zexcel_cell_style OPTIONAL
|
||||
!ip_body_style TYPE zexcel_cell_style OPTIONAL
|
||||
!ip_hdr_style TYPE any OPTIONAL
|
||||
!ip_body_style TYPE any OPTIONAL
|
||||
!ip_table_title TYPE string
|
||||
!ip_top_left_column TYPE zexcel_cell_column_alpha DEFAULT 'B'
|
||||
!ip_top_left_row TYPE zexcel_cell_row DEFAULT 3
|
||||
|
@ -601,7 +605,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_column_end TYPE simple OPTIONAL
|
||||
!ip_row TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_row_to TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style OPTIONAL
|
||||
!ip_style TYPE any OPTIONAL
|
||||
RAISING
|
||||
zcx_excel .
|
||||
METHODS set_area_formula
|
||||
|
@ -623,7 +627,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_column_end TYPE simple OPTIONAL
|
||||
!ip_row TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_row_to TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style
|
||||
!ip_style TYPE any
|
||||
!ip_merge TYPE abap_bool OPTIONAL
|
||||
RAISING
|
||||
zcx_excel .
|
||||
|
@ -636,7 +640,7 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
!ip_row_to TYPE zexcel_cell_row OPTIONAL
|
||||
!ip_value TYPE simple OPTIONAL
|
||||
!ip_formula TYPE zexcel_cell_formula OPTIONAL
|
||||
!ip_style TYPE zexcel_cell_style OPTIONAL
|
||||
!ip_style TYPE any OPTIONAL
|
||||
!ip_hyperlink TYPE REF TO zcl_excel_hyperlink OPTIONAL
|
||||
!ip_data_type TYPE zexcel_cell_data_type OPTIONAL
|
||||
!ip_abap_type TYPE abap_typekind OPTIONAL
|
||||
|
@ -766,6 +770,13 @@ CLASS zcl_excel_worksheet DEFINITION
|
|||
ep_row_to TYPE zexcel_cell_row
|
||||
RAISING
|
||||
zcx_excel.
|
||||
CLASS-METHODS normalize_style_parameter
|
||||
IMPORTING
|
||||
!ip_style_or_guid TYPE any
|
||||
RETURNING
|
||||
VALUE(rv_guid) TYPE zexcel_cell_style
|
||||
RAISING
|
||||
zcx_excel .
|
||||
METHODS print_title_set_range .
|
||||
METHODS update_dimension_range
|
||||
RAISING
|
||||
|
@ -2970,6 +2981,35 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD normalize_style_parameter.
|
||||
|
||||
DATA: lo_style_type TYPE REF TO cl_abap_typedescr.
|
||||
FIELD-SYMBOLS:
|
||||
<style> TYPE REF TO zcl_excel_style.
|
||||
|
||||
CHECK ip_style_or_guid IS NOT INITIAL.
|
||||
|
||||
lo_style_type = cl_abap_typedescr=>describe_by_data( ip_style_or_guid ).
|
||||
IF lo_style_type->type_kind = lo_style_type->typekind_oref.
|
||||
lo_style_type = cl_abap_typedescr=>describe_by_object_ref( ip_style_or_guid ).
|
||||
IF lo_style_type->absolute_name = '\CLASS=ZCL_EXCEL_STYLE'.
|
||||
ASSIGN ip_style_or_guid TO <style>.
|
||||
rv_guid = <style>->get_guid( ).
|
||||
ENDIF.
|
||||
|
||||
ELSEIF lo_style_type->absolute_name = '\TYPE=ZEXCEL_CELL_STYLE'.
|
||||
rv_guid = ip_style_or_guid.
|
||||
|
||||
ELSEIF lo_style_type->type_kind = lo_style_type->typekind_hex.
|
||||
rv_guid = ip_style_or_guid.
|
||||
|
||||
ELSE.
|
||||
RAISE EXCEPTION TYPE zcx_excel EXPORTING error = 'IP_GUID type must be either REF TO zcl_excel_tyle or zexcel_cell_style'.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD print_title_set_range.
|
||||
*--------------------------------------------------------------------*
|
||||
* issue#235 - repeat rows/columns
|
||||
|
@ -3353,11 +3393,11 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
|
|||
lv_style_guid = <fs_sheet_content>-cell_style.
|
||||
ELSE.
|
||||
" Style provided as method-parameter --> use this
|
||||
lv_style_guid = ip_style.
|
||||
lv_style_guid = normalize_style_parameter( ip_style ).
|
||||
ENDIF.
|
||||
ELSE.
|
||||
" No cell found --> use supplied style even if empty
|
||||
lv_style_guid = ip_style.
|
||||
lv_style_guid = normalize_style_parameter( ip_style ).
|
||||
ENDIF.
|
||||
* End of change issue #152 - don't touch exisiting style if only value is passed
|
||||
|
||||
|
@ -3605,7 +3645,7 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
|
|||
|
||||
FIELD-SYMBOLS: <fs_sheet_content> TYPE zexcel_s_cell_data.
|
||||
|
||||
lv_style_guid = ip_style.
|
||||
lv_style_guid = normalize_style_parameter( ip_style ).
|
||||
|
||||
normalize_columnrow_parameter( EXPORTING ip_columnrow = ip_columnrow
|
||||
ip_column = ip_column
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
CLASS ltc_normalize_columnrow_param DEFINITION DEFERRED.
|
||||
CLASS ltc_normalize_range_param DEFINITION DEFERRED.
|
||||
CLASS ltc_normalize_style_param DEFINITION DEFERRED.
|
||||
CLASS ltc_check_cell_column_formula DEFINITION DEFERRED.
|
||||
CLASS zcl_excel_worksheet DEFINITION LOCAL FRIENDS
|
||||
ltc_normalize_columnrow_param
|
||||
ltc_normalize_range_param
|
||||
ltc_normalize_style_param
|
||||
ltc_check_cell_column_formula.
|
||||
|
||||
CLASS lcl_excel_worksheet_test DEFINITION FOR TESTING
|
||||
|
@ -140,6 +142,38 @@ CLASS ltc_normalize_range_param DEFINITION FOR TESTING
|
|||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_normalize_style_param DEFINITION FOR TESTING
|
||||
RISK LEVEL HARMLESS
|
||||
DURATION SHORT.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES : BEGIN OF ty_parameters_output,
|
||||
fails TYPE abap_bool,
|
||||
guid TYPE zexcel_cell_style,
|
||||
END OF ty_parameters_output.
|
||||
DATA:
|
||||
excel TYPE REF TO zcl_excel,
|
||||
cut TYPE REF TO zcl_excel_worksheet, "class under test
|
||||
exp TYPE ty_parameters_output.
|
||||
|
||||
|
||||
METHODS setup.
|
||||
METHODS:
|
||||
ref_to_zcl_excel_style FOR TESTING RAISING cx_static_check,
|
||||
zexcel_cell_style FOR TESTING RAISING cx_static_check,
|
||||
raw_16_bytes FOR TESTING RAISING cx_static_check,
|
||||
other FOR TESTING RAISING cx_static_check.
|
||||
|
||||
METHODS assert
|
||||
IMPORTING
|
||||
input TYPE any
|
||||
exp TYPE ty_parameters_output
|
||||
RAISING
|
||||
cx_static_check.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS lcl_excel_worksheet_test IMPLEMENTATION.
|
||||
* ==============================================
|
||||
|
||||
|
@ -868,3 +902,95 @@ CLASS ltc_normalize_range_param IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_normalize_style_param IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
|
||||
CREATE OBJECT excel.
|
||||
|
||||
TRY.
|
||||
CREATE OBJECT cut
|
||||
EXPORTING
|
||||
ip_excel = excel.
|
||||
CATCH zcx_excel.
|
||||
cl_abap_unit_assert=>fail( 'Could not create instance' ).
|
||||
ENDTRY.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ref_to_zcl_excel_style.
|
||||
DATA: style TYPE REF TO zcl_excel_style.
|
||||
|
||||
style = excel->add_new_style( ).
|
||||
exp-fails = abap_false.
|
||||
exp-guid = style->get_guid( ).
|
||||
assert( input = style exp = exp ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zexcel_cell_style.
|
||||
DATA: style TYPE REF TO zcl_excel_style.
|
||||
|
||||
style = excel->add_new_style( ).
|
||||
exp-fails = abap_false.
|
||||
exp-guid = style->get_guid( ).
|
||||
assert( input = exp-guid exp = exp ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD raw_16_bytes.
|
||||
DATA: raw_16_bytes TYPE x LENGTH 16.
|
||||
|
||||
raw_16_bytes = 'A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1'.
|
||||
exp-fails = abap_false.
|
||||
exp-guid = raw_16_bytes.
|
||||
assert( input = raw_16_bytes exp = exp ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD other.
|
||||
|
||||
exp-fails = abap_true.
|
||||
assert( input = 'A' exp = exp ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert.
|
||||
DATA: rtti TYPE REF TO cl_abap_typedescr,
|
||||
message TYPE string,
|
||||
act TYPE zexcel_cell_style,
|
||||
error TYPE REF TO zcx_excel,
|
||||
input_text TYPE string.
|
||||
|
||||
rtti = cl_abap_typedescr=>describe_by_data( input ).
|
||||
IF rtti->type_kind = rtti->typekind_oref.
|
||||
rtti = cl_abap_typedescr=>describe_by_object_ref( input ).
|
||||
input_text = |REF TO { rtti->absolute_name }|.
|
||||
ELSE.
|
||||
input_text = rtti->absolute_name.
|
||||
ENDIF.
|
||||
|
||||
TRY.
|
||||
|
||||
act = cut->normalize_style_parameter( input ).
|
||||
|
||||
IF exp-fails = abap_true.
|
||||
message = |Input type { input_text } accepted but only REF TO \\CLASS=ZCL_EXCEL_STYLE, \\TYPE=ZEXCEL_CELL_STYLE or any X type are supported|.
|
||||
cl_abap_unit_assert=>fail( msg = message ).
|
||||
ENDIF.
|
||||
|
||||
CATCH zcx_excel INTO error.
|
||||
IF exp-fails = abap_false.
|
||||
message = |Input type { input_text } made it fail but it should succeed with result { exp-guid }|.
|
||||
cl_abap_unit_assert=>fail( msg = message ).
|
||||
ENDIF.
|
||||
RETURN.
|
||||
ENDTRY.
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = exp-guid act = act ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user