1. 代码
-
实现单元格增加图标代码
DATA: lo_excel TYPE REF TO zcl_excel, lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_style_conditional TYPE REF TO zcl_excel_style_conditional. DATA: ls_iconset3 TYPE zexcel_conditional_iconset, ls_iconset4 TYPE zexcel_conditional_iconset, ls_iconset5 TYPE zexcel_conditional_iconset, ls_databar TYPE zexcel_conditional_databar, ls_colorscale2 TYPE zexcel_conditional_colorscale, ls_colorscale3 TYPE zexcel_conditional_colorscale. CONSTANTS: gc_save_file_name TYPE string VALUE 'zdemo_excel.xlsx'. INCLUDE zdemo_excel_outputopt_incl. START-OF-SELECTION. CREATE OBJECT lo_excel. ls_iconset3-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset3-cfvo1_value = '0'. ls_iconset3-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset3-cfvo2_value = '33'. ls_iconset3-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset3-cfvo3_value = '66'. ls_iconset3-showvalue = zcl_excel_style_conditional=>c_showvalue_true. ls_iconset4-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset4-cfvo1_value = '0'. ls_iconset4-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset4-cfvo2_value = '25'. ls_iconset4-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset4-cfvo3_value = '50'. ls_iconset4-cfvo4_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset4-cfvo4_value = '75'. ls_iconset4-showvalue = zcl_excel_style_conditional=>c_showvalue_true. ls_iconset5-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset5-cfvo1_value = '0'. ls_iconset5-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset5-cfvo2_value = '20'. ls_iconset5-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset5-cfvo3_value = '40'. ls_iconset5-cfvo4_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset5-cfvo4_value = '60'. ls_iconset5-cfvo5_type = zcl_excel_style_conditional=>c_cfvo_type_percent. ls_iconset5-cfvo5_value = '80'. ls_iconset5-showvalue = zcl_excel_style_conditional=>c_showvalue_true. ls_databar-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min. ls_databar-cfvo1_value = '0'. ls_databar-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_max. ls_databar-cfvo2_value = '0'. ls_databar-colorrgb = 'FF638EC6'. ls_colorscale2-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min. ls_colorscale2-cfvo1_value = '0'. ls_colorscale2-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percentile. ls_colorscale2-cfvo2_value = '50'. ls_colorscale2-colorrgb1 = 'FFF8696B'. ls_colorscale2-colorrgb2 = 'FF63BE7B'. ls_colorscale3-cfvo1_type = zcl_excel_style_conditional=>c_cfvo_type_min. ls_colorscale3-cfvo1_value = '0'. ls_colorscale3-cfvo2_type = zcl_excel_style_conditional=>c_cfvo_type_percentile. ls_colorscale3-cfvo2_value = '50'. ls_colorscale3-cfvo3_type = zcl_excel_style_conditional=>c_cfvo_type_max. ls_colorscale3-cfvo3_value = '0'. ls_colorscale3-colorrgb1 = 'FFF8696B'. ls_colorscale3-colorrgb2 = 'FFFFEB84'. ls_colorscale3-colorrgb3 = 'FF63BE7B'. " Get active sheet lo_worksheet = lo_excel->get_active_worksheet( ). * ICONSET lo_style_conditional = lo_worksheet->add_new_conditional_style( ). lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. lo_style_conditional->priority = 1. ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3arrows. lo_style_conditional->mode_iconset = ls_iconset3. lo_style_conditional->set_range( ip_start_column = 'B' ip_start_row = 5 ip_stop_column = 'B' ip_stop_row = 9 ). lo_worksheet->set_cell( ip_row = 4 ip_column = 'B' ip_value = 'C_ICONSET_3ARROWS' ). lo_worksheet->set_cell( ip_row = 5 ip_column = 'B' ip_value = 10 ). lo_worksheet->set_cell( ip_row = 6 ip_column = 'B' ip_value = 20 ). lo_worksheet->set_cell( ip_row = 7 ip_column = 'B' ip_value = 30 ). lo_worksheet->set_cell( ip_row = 8 ip_column = 'B' ip_value = 40 ). lo_worksheet->set_cell( ip_row = 9 ip_column = 'B' ip_value = 50 ). lo_style_conditional = lo_worksheet->add_new_conditional_style( ). lo_style_conditional->rule = zcl_excel_style_conditional=>c_rule_iconset. lo_style_conditional->priority = 1. ls_iconset3-iconset = zcl_excel_style_conditional=>c_iconset_3arrowsgray. lo_style_conditional->mode_iconset = ls_iconset3. lo_style_conditional->set_range( ip_start_column = 'C' ip_start_row = 5 ip_stop_column = 'C' ip_stop_row = 9 ). lo_worksheet->set_cell( ip_row = 4 ip_column = 'C' ip_value = 'C_ICONSET_3ARROWSGRAY' ). lo_worksheet->set_cell( ip_row = 5 ip_column = 'C' ip_value = 10 ). lo_worksheet->set_cell( ip_row = 6 ip_column = 'C' ip_value = 20 ). lo_worksheet->set_cell( ip_row = 7 ip_column = &#