SAP ABAP2XLSX 单元格图标展示之ZDEMO_EXCEL7

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 = &#
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值