Different colors in alv cell

Hello experts,
I use reuse_Alv for displaying my alv.
I use this command to color single cells background color
  LOOP AT gt_mytab  INTO ls_mytab.
    ld_index = sy-tabix.
    IF ls_mytab-expstatus = '0000'.
      wa_cellcolor-fname = 'EXPSTATUS'.
      "color code 1-7, if outside rage defaults to 7
      wa_cellcolor-color-col = 5.
      "1 = Intensified on, 0 = Intensified off
      wa_cellcolor-color-int = '0'.
      "1 = text colour, 0 = background colour
      wa_cellcolor-color-inv = '0'.
      APPEND wa_cellcolor TO ls_mytab-cellcolor.
      MODIFY gt_mytab FROM ls_mytab INDEX ld_index
      TRANSPORTING cellcolor.
    ENDIF.
  ENDLOOP.
But what if i wanted to color the cell background fx. yellow and the text in the cell green, is this possible?
Thanks in advance.
Kenneth

Hi Kenneth,
Try to use '-emphasize' field to adjust cell that you are going to set.
Or, please refer to this [link|http://forums.sdn.sap.com/thread.jspa?threadID=1336861].
Hope it helps.
Regards,
Dondi.

Similar Messages

  • How can i apply different color for each cell in jlist component?

    hi guys i need your help and sorry if my english is very bad..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..
    Edited by: ryrene on Mar 21, 2010 12:13 AM

    ryrene wrote:
    hi guys i need your help and sorry if my english is very bad.
    ..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..I'll see your tnx, and raise you dve bmbrs & nplm.

  • Fill colors to ALV cells

    Hi All,
    How can I display multiple colors to different cells in an ALV ?.
    Please help..
    Thanks in advance,
    sudeep v d..

    Hi Sudeep,
    In the below mentioned link a topic Color of ALV output, columns, and cells has been mentioned in the section '4.17.3 Appearance of ALV Output'.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aeaa1fefd706
    Best regards,
    Suresh

  • Coloring an ALV Cell with DYNAMIC INTERNAL TABLES

    Hello Gurus,
    I need your help regarding coloring of a cell in my ALV Grid report with DYNAMIC tables.
    I have used the call method in calling my ALV. (CALL METHOD gr_alvgrid->set_table_for_first_display).
    Now my problem is, I can not bring out the cellcolor succesfully, I always ended up to dump (GETWA_NOT_ASSIGNED = You attempted to access an unassigned field symbol     
    (data segment 32807).                                  
    What I have done:
    I've created 2 internal tables:
    *1st table
    *After appended all of my columns to  gt_fieldcat
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gt_fieldcat
        IMPORTING
          ep_table        = gp_both.
      ASSIGN gp_both->* TO <i_xtab1>.
    *2nd table
    Appended these column for CellColor
      CLEAR wa_gtfldcat.
      wa_gtfldcat-fieldname = 'CELLCOLOR'.
      wa_gtfldcat-ref_table = 'CALENDAR_TYPE'.
      wa_gtfldcat-ref_field = 'COLTAB'.
      APPEND wa_gtfldcat TO gt_fieldcat.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = gt_fieldcat
        IMPORTING
          ep_table        = gp_alvgrid.
      ASSIGN gp_alvgrid->* TO <i_xtab2>.
    *Work Areas for tab1 and tab2
    CREATE DATA dref1 LIKE LINE OF <i_xtab1>.
      ASSIGN dref1->* TO <wa_xtab1>.
      CREATE DATA dref2 LIKE LINE OF <i_xtab2>.
      ASSIGN dref2->* TO <wa_xtab2>.
    *Move contents of table1 to table2 and modify cellcolor column
    LOOP AT <i_xtab1> ASSIGNING <wa_xtab1>.
    *-----Cell color assignment
        DESCRIBE TABLE gt_fieldcat.
        DO sy-tfill TIMES.
          READ TABLE gt_fieldcat INTO wa_gtfldcat INDEX sy-index.
          ASSIGN COMPONENT wa_gtfldcat-fieldname
            OF STRUCTURE <wa_xtab1> TO <fs4>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT wa_gtfldcat-fieldname
            OF STRUCTURE <wa_xtab2> TO <fs3>.
          IF sy-subrc NE 0. EXIT .ENDIF.
            <fs3> = <fs4>.
        ENDDO.
        ASSIGN COMPONENT 'CELLCOLOR' OF STRUCTURE <wa_xtab2> TO <fs3>.
        IF sy-subrc = 0.
          PERFORM modify_cell_color USING 'ZZMATNR' <fs3>.
        ENDIF.
        APPEND <wa_xtab1> TO <i_xtab2>.
    ENDLOOP.
    *Call ALV
    gs_layout-ctab_fname = 'COLORCELL'
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_layout                     = gs_layout
          CHANGING
            it_outtab                     = <i_xtab2d>[]
            it_fieldcatalog               = gt_fieldcat
            it_sort                       = lt_sort
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
    *--->Exception handling
        ENDIF.
    FORM modify_cell_color  USING p_fieldname   TYPE lvc_fname
                                  pt_cellcolor  TYPE table.
      DATA l_cellcolor TYPE lvc_s_scol.
      CLEAR l_cellcolor.
      l_cellcolor-fname = p_fieldname.
      l_cellcolor-color-col = 6.       " Red.
      l_cellcolor-color-int = 0.
      l_cellcolor-color-inv = 0.
      INSERT l_cellcolor INTO TABLE pt_cellcolor.
    ENDFORM.                    " MODIFY_CELL_COLOR

    Hi,
    The internal tabl which you are using to display the output should have one column in the end.
    The cell in this column will contain an internal table of type 'lvc_s_scol'.
    The contents of this internal table will be the field names of all other columns of your main internal table in the field FNAME and the required color in the field COLOR.
    Please note that the field COLOR will have a hex value for different colors.
    In the stucture is_layout  whihc you pass to the method 'set_table_for_first_display'
    the name of this last column should be given to the field 'ctab_fname'.
    This will help you to give the colors to each cell.
    for example
    I have my data table as follows:-
    ITAB1
    MATNR  MAKTX        COLOR_TAB
    1           ABC            FNAME  COLOR  NOKEYCOL
                                    MATNR 8000
                                    MAKTX 8000
    2          XYZ             MATNR 10000
                                  MAKTX  10000
    So my internal table ITAB1 had 3 columns MATNR MAKTX and COLOR_TAB.
    And COLOR_TAB will contain an internal table with 3 columns FNAME COLOR and NOKEYCOL.
    The value to importing parameter IS_LAYOUT-CTAB_FNAME will be COLOR_TAB.
    This will help you to assign various colors to the cell of the internal table ITAB.
    When you have to change any color, then you will have to just change the entries in cell COLOR_TAB for the particular row and cell.
    Regards,
    Ankur Parab

  • Color in alv ( cell)

    hello
    i tried to color only some cells in alv but i want just what i write will be colored and not all the row
    for exmaple:
    if i have in one row the value 500 i want just the 500 will have color and not all the row
    thanks

    Hi,
    here is another sample report..
    report zc9_alvgrid_final_now .
    *PROGRAM ON ALV-GRID.
    *TABLE DECLARATION.
    *tables:zc9_employee, zc9_empspec.
    type-pools: slis. "ALV Declarations
    data: celcol1 type slis_specialcol_alv.
    data: syprindex type i value 1.
    *INTERNAL TABLE DECLARATION.
    data: begin of itab_alv1 OCCURS 0,
    emp_id(5) TYPE C,
    emp_name(20) TYPE C,
    certified(3) TYPE C,
    celcol type slis_t_specialcol_alv,
    selected(1) type c,
    end of itab_alv1.
    data: begin of itab_alv3 OCCURS 0,
    emp_id(5) TYPE C,
    emp_name(20) TYPE C,
    certified(3) TYPE C,
    end of itab_alv3.
    data: mulrowtab1 like line of itab_alv1.
    data: mulrowtab like table of itab_alv1.
    data: wa_emp_name like zc9_employee-emp_name.
    data: mulrowindex type i value 1.
    data: maxlines type i.
    data: wa like line of itab_alv1.
    data: wa_itab like line of itab_alv1.
    data: ok-code like sy-ucomm.
    data: ok-code1 like sy-ucomm.
    data: ind type i.
    data: newvar type disvariant.
    data: tempvar type i value 0.
    data: gd_repid like sy-repid.
    *ALV-GRID DATA DECLARATION.
    data: fieldcatalog type slis_t_fieldcat_alv.
    * FIELD CATALOG.
    data: fieldcatalog1 type slis_fieldcat_alv.
    data: gd_layout type slis_layout_alv.
    * LAYOUT DECLARATION.
    data: id_color type c.
    data: eventtable type slis_t_event.
    data: wa_event type slis_alv_event.
    data: newvariant type disvariant.
    data: i_exclude type slis_t_extab, "ALV Exclusion Table
    wa_exclude type slis_extab. "ALV Exclusion Structure
    *VARIANT DECLARATION.
    data: vartype like disvariant.
    data: var_save(1) type c.
    data: w_exit(1) type c.
    data: wx_variant like disvariant.
    data: variant_para like disvariant-variant.
    data: itab_emp like table of zc9_employee.
    data: itab_emp1 like line of itab_emp.
    data: itab_spec like table of zc9_empspec.
    data: itab_spec1 like line of itab_spec.
    data: ls_sort type slis_sortinfo_alv.
    data: lt_sort type slis_t_sortinfo_alv.
    parameter: LAYOUT like disvariant-variant.
    * INITIALIZATION.
    gd_repid = sy-repid.
    *CALLING SELECTION SCREEN-SUBROUTINES.
    *AT SELECTION SCREEN
    at selection-screen output.
    perform init_variant.
    perform variant_default using LAYOUT.
    at selection-screen on value-request for LAYOUT.
    perform variant_select using LAYOUT.
    at selection-screen.
    perform variant_fill.
    newvar = vartype.
    * LAYOUT DECLARATION.
    gd_layout-zebra = 'X'.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-box_fieldname = 'SELECTED'.
    gd_layout-box_tabname = 'ITAB_ALV1'.
    gd_layout-totals_text = 'Totals'(201).
    gd_layout-coltab_fieldname = 'CELCOL'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    * "click(press f2)
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = gd_repid
    i_internal_tabname = 'ITAB_ALV3'
    i_inclname = gd_repid
    changing
    ct_fieldcat = fieldcatalog
    *FIELD-CATALOG DECLARATION.
    loop at fieldcatalog into fieldcatalog1.
    case fieldcatalog1-fieldname.
    when 'EMP_ID'.
    fieldcatalog1-seltext_m = 'EMP-ID'.
    fieldcatalog1-col_pos = 0.
    fieldcatalog1-outputlen = 10.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-do_sum = 'X'.
    fieldcatalog1-sp_group = 'A'.
    when 'EMP_NAME'.
    fieldcatalog1-fieldname = 'EMP_NAME'.
    fieldcatalog1-seltext_m = 'EMPLOYEE_NAME'.
    fieldcatalog1-col_pos = 1.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-hotspot = 'X'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-outputlen = 20.
    fieldcatalog1-sp_group = 'B'.
    when 'CERTIFIED'.
    fieldcatalog1-fieldname = 'CERTIFIED'.
    fieldcatalog1-seltext_m = 'CERTIFIED'.
    fieldcatalog1-col_pos = 2.
    fieldcatalog1-emphasize = 'C2'.
    fieldcatalog1-key = 'X'.
    fieldcatalog1-sp_group = 'C'.
    endcase.
    modify fieldcatalog from fieldcatalog1.
    endloop.
    *SORTING FIELD CATALOG FIELD.
    ls_sort-spos = 1.
    ls_sort-fieldname = 'EMP_ID'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    append ls_sort to lt_sort.
    *POPULATING THE INTERNAL TABLE.
    ITAB_ALV1-EMP_ID = '15530'.
    ITAB_ALV1-EMP_NAME = 'THILAKJI'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15531'.
    ITAB_ALV1-EMP_NAME = 'MATHEWS'.
    ITAB_ALV1-CERTIFIED = 'NO'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15532'.
    ITAB_ALV1-EMP_NAME = 'JAISI'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15533'.
    ITAB_ALV1-EMP_NAME = 'ADAMS'.
    ITAB_ALV1-CERTIFIED = 'YES'.
    APPEND ITAB_ALV1.
    ITAB_ALV1-EMP_ID = '15534'.
    ITAB_ALV1-EMP_NAME = 'PAUL'.
    ITAB_ALV1-CERTIFIED = 'NO'.
    APPEND ITAB_ALV1.
    * FORM TO MAKE THE CELL CONTENTS INVISIBLE.
    PERFORM INVISIBLE_CELL_CONTENTS.
    *EXCLUDE-DECLARATION.
    clear wa_exclude.
    wa_exclude-fcode = '&VEXCEL'.
    append wa_exclude to i_exclude.
    * FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE2' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = 'ALV GRID-EMPLOYEE'
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_sort = lt_sort
    it_excluding = i_exclude
    i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
    i_save = 'A'
    is_variant = newvar
    tables
    t_outtab = itab_alv1
    exceptions
    program_error = 1
    others = 2.
    * Form TOP-OF-PAGE *
    * ALV Report Header *
    form top-of-page2.
    data: header type slis_t_listheader,
    wa type slis_listheader,
    infield like wa-info,
    nline type i,
    nlinechar(2) type c.
    *TITLE AREA
    wa-typ = 'H'.
    wa-info = 'EMPLOYEE-DETAILS'.
    append wa to header.
    *BELOW AREA.
    wa-typ = 'S'.
    wa-key = 'DATE'.
    concatenate sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) into wa-info
    append wa to header.
    *NEXT LINE.
    wa-typ = 'S'.
    describe table itab_alv1 lines nline.
    nlinechar = nline.
    wa-key = 'TABLE DETAILS'.
    concatenate 'NO.of.Lines:' nlinechar into wa-info separated by space.
    append wa to header.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = header
    i_logo = 'ALVLOGO'.
    endform.
    * FORM SET_PF_STATUS *
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWSTATUS123'.
    endform.
    * FORM USER_COMMAND *
    * --> R_UCOMM *
    * --> RS_SELFIELD *
    form user_command using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield.
    * Check function code
    case r_ucomm.
    when 'SELM'.
    loop at itab_alv1 where selected = 'X'.
    move-corresponding itab_alv1 to mulrowtab1.
    append mulrowtab1 to mulrowtab.
    endloop.
    message i029(zmc).
    clear mulrowtab1.
    when 'DISP'.
    * Check field clicked on within ALVgrid report
    if rs_selfield-fieldname = 'EMP_ID'.
    * Read data table, using index of row user clicked on
    read table itab_alv1 into wa index rs_selfield-tabindex.
    ind = rs_selfield-tabindex.
    message i025(zmc) with rs_selfield-fieldname .
    elseif rs_selfield-fieldname = 'EMP_NAME'.
    read table itab_alv1 into wa index rs_selfield-tabindex.
    ind = rs_selfield-tabindex.
    message i028(zmc) with rs_selfield-fieldname wa-emp_name .
    endif.
    when 'EXIT'.
    * MESSAGE I026(ZMC).
    leave program.
    when 'CHAN'.
    * READ TABLE itab_alv1 INTO wa INDEX rs_selfield-tabindex.
    read table itab_alv1 into wa index rs_selfield-tabindex.
    call screen 1551.
    tempvar = 1.
    *CALLING THE GRID DISPLAY FUNCTION AGAIN.
    * FUNCTION MODULE CALL-REUSE-ALV-GRID-DISPLAY.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = 'ALV GRID-EMPLOYEE'
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_events = eventtable
    i_save = 'X'
    it_excluding = i_exclude
    i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
    is_variant = newvar
    tables
    t_outtab = itab_alv1
    exceptions
    program_error = 1
    others = 2.
    r_ucomm = '&F03'.
    when '&F03'.
    * IF TEMPVAR = 1.
    leave program.
    endcase.
    clear r_ucomm.
    endform.
    *& Module USER_COMMAND_1551 INPUT
    * text
    module user_command_1551 input.
    data: syprtabix type i.
    case ok-code.
    when 'QUIT'.
    set screen 0.
    leave screen.
    clear itab_alv1.
    sy-tabix = 0.
    when 'UPDA'.
    loop at itab_alv1 where emp_id = wa-emp_id.
    syprtabix = sy-tabix.
    endloop.
    modify itab_alv1 from wa index syprtabix transporting emp_id emp_name
    certified.
    message i027(zmc).
    leave screen.
    endcase.
    endmodule. " USER_COMMAND_1551 INPUT
    *& Module STATUS_1551 OUTPUT
    * text
    module status_1551 output.
    set pf-status 'ZNEWSTATUS'.
    * SET TITLEBAR 'xxx'.
    endmodule. " STATUS_1551 OUTPUT
    *FORM FOR SELECTING LAYOUT.
    form variant_select using form_varpar.
    call function 'LVC_VARIANT_F4'
    exporting
    is_variant = vartype
    * IT_DEFAULT_FIELDCAT =
    i_save = var_save
    importing
    e_exit = w_exit
    es_variant = wx_variant
    exceptions
    not_found = 1
    program_error = 2
    others = 3
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    if w_exit is initial.
    vartype-variant = wx_variant-variant.
    form_varpar = wx_variant-variant.
    endif.
    endform.
    *& Form init_variant
    form init_variant.
    clear: vartype.
    gd_repid = sy-repid.
    vartype-report = sy-repid.
    vartype-username = sy-uname.
    var_save = 'A'. "All types
    endform.
    *& Form variant_default
    form variant_default using p_variant.
    wx_variant = vartype.
    if not p_variant is initial.
    wx_variant-variant = p_variant.
    endif.
    call function 'LVC_VARIANT_DEFAULT_GET'
    exporting
    i_save = var_save
    changing
    cs_variant = wx_variant
    exceptions
    wrong_input = 1
    not_found = 2
    program_error = 3
    others = 4.
    case sy-subrc.
    when 0.
    p_variant = wx_variant-variant.
    when 2.
    clear: p_variant.
    endcase.
    endform.
    *& Form variant_fill
    form variant_fill.
    clear: vartype.
    if LAYOUT is initial.
    vartype-variant = 'STANDARD'.
    vartype-report = sy-repid.
    else.
    vartype-variant = LAYOUT.
    vartype-report = sy-repid.
    call function 'LVC_VARIANT_EXISTENCE_CHECK'
    exporting
    i_save = var_save
    changing
    cs_variant = vartype
    exceptions
    others = 01.
    if sy-subrc ne 0.
    message i000(zz) with text-g02.
    endif.
    endif.
    endform.
    *& Module STATUS_1234 OUTPUT
    * text
    module status_1234 output.
    * SET PF-STATUS 'xxxxxxxx'.
    * SET TITLEBAR 'xxx'.
    endmodule. " STATUS_1234 OUTPUT
    *& Module USER_COMMAND_1234 INPUT
    * text
    module user_command_1234 input.
    sort mulrowtab.
    describe table mulrowtab lines maxlines.
    case ok-code1.
    when 'OUT1'.
    set screen 0.
    leave screen.
    when 'PUSH'.
    clear mulrowtab1.
    if mulrowindex <= maxlines.
    read table mulrowtab into mulrowtab1 index mulrowindex.
    mulrowindex = mulrowindex + 1.
    else.
    message i030(zmc).
    endif.
    endcase.
    endmodule. " USER_COMMAND_1234 INPUT
    * CEL COLOR TABLE POPULATION.
    FORM INVISIBLE_CELL_CONTENTS.
    loop at itab_alv1 INTO WA.
    IF WA-EMP_ID = ' '.
    EXIT.
    ENDIF.
    clear itab_alv1.
    move-corresponding WA to itab_alv1.
    clear celcol1.
    celcol1-fieldname = 'EMP_ID'.
    celcol1-color-col = syprindex.
    append celcol1 to itab_alv1-celcol.
    celcol1-fieldname = 'EMP_NAME'.
    celcol1-color-col = syprindex + 2.
    append celcol1 to itab_alv1-celcol.
    * CODE FOR MAKING THE GRID CELL CONTENTS INVISIBLE BASED ON THE VALUE OF
    *THE CELL.THE CONDITION CHECKED IS WHETHER
    * CERTIFIED FIELD HAS VALUE 'NO'.
    celcol1-fieldname = 'CERTIFIED'.
    if itab_alv1-certified = 'NO'.
    itab_alv1-emp_name = ' '.
    endif.
    celcol1-color-col = syprindex + 3.
    append celcol1 to itab_alv1-celcol.
    MODIFY ITAB_ALV1.
    syprindex = celcol1-color-col - 1.
    CLEAR ITAB_ALV1.
    endloop.
    ENDFORM.
    Regards,
    Suresh Datti

  • How to set input ready query cell is different color?

    Dear All
      Hi, everyone, hereby i have a IP question.
      i would like to know, how to set the input ready query's cell different color between those cell which is unable to change value one in workbook..?
    Example :
      For my workbook which have a input ready query,
      i have 4 rows for my input ready query report.
      For the first row which is not input ready cell and unable to change any value for the cell, then following rows's cell can be change value,
      so, i would like to make first row's color cell different with following row's cell.
      In additional, all value of cell is initial zero.
      therefore, is there any mehtod to make different color between able cell and unable cell?
    Thanks a million.
    Regards,
    WenLong.

    Cells in the input ready query result have different styles given by SAP. All rows will have one style, column headings will have one style whereas input ready cells will have one style. If you are in Excel 2003, put cursor in the input ready cell, goto format -> style, you can see one BeX style attached to that cell, apply watever color you want for that style, save the workbook. If you do this for one cell, it will be applied to all the input ready cells by default. In the same way you can give different color to the non input ready cell styles. In Excel 2007, Cell styles are available in Home -> Cell styles. Here you can see all Bex related styles.

  • Button to change bg-color in JTable cell

    Hello!
    I would like to change the background color of a cell with a klick on a button.
    There will be 3 colors, and the selected cell are the only one thats going to change.
    How do I do that?
    Heres my code:
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Rectangle;
    import javax.swing.JButton;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableColumnModel;
    import javax.swing.table.TableModel;
    public class Kinna extends JFrame {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTabbedPane jTabbedPane = null;
         private JScrollPane jScrollPane = null;
         private JTable jTable = null;
         private JButton jButtonRed = null;
         private JButton jButtonGreen = null;
         private JButton jButtonBlue = null;
         private JButton jButtonNewWeek = null;
         private JButton jButtonDelWeek = null;
          * This method initializes jTabbedPane     
          * @return javax.swing.JTabbedPane     
         private JTabbedPane getJTabbedPane() {
              if (jTabbedPane == null) {
                   jTabbedPane = new JTabbedPane();
                   jTabbedPane.setBounds(new Rectangle(105, 45, 545, 488));
                   jTabbedPane.addTab(null, null, getJScrollPane(), null);
              return jTabbedPane;
          * This method initializes jScrollPane     
          * @return javax.swing.JScrollPane     
         private JScrollPane getJScrollPane() {
              if (jScrollPane == null) {
                   jScrollPane = new JScrollPane();
                   jScrollPane.setViewportView(getJTable());
              return jScrollPane;
          * This method initializes jTable     
          * @return javax.swing.JTable     
         private JTable getJTable() {
              if (jTable == null) {
                   Object[] head = {"Namn", "M�ndag", "Tisdag", "Onsdag", "Torsdag", "Fredag"};
                   Object[][] data = {{"Niklas", "9-15", "9-15", "9-15", "9-15","9-15"},
                                            {"Niklas", "9-15", "9-15", "9-15", "9-15","9-15"}};
                   jTable = new JTable(data, head);
                      // This table shades every other column yellow
              return jTable;
          * This method initializes jButtonRed     
          * @return javax.swing.JButton     
         private JButton getJButtonRed() {
              if (jButtonRed == null) {
                   jButtonRed = new JButton("R�d");
                   jButtonRed.setBounds(new Rectangle(15, 30, 76, 31));
                   jButtonRed.setText("R�d");
                   jButtonRed.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
              return jButtonRed;
          * This method initializes jButtonGreen     
          * @return javax.swing.JButton     
         private JButton getJButtonGreen() {
              if (jButtonGreen == null) {
                   jButtonGreen = new JButton("R�d");
                   jButtonGreen.setBounds(new Rectangle(15, 75, 76, 31));
                   jButtonGreen.setText("Gr�n");
              return jButtonGreen;
          * This method initializes jButtonBlue     
          * @return javax.swing.JButton     
         private JButton getJButtonBlue() {
              if (jButtonBlue == null) {
                   jButtonBlue = new JButton("R�d");
                   jButtonBlue.setBounds(new Rectangle(15, 120, 76, 31));
                   jButtonBlue.setText("Bl�");
              return jButtonBlue;
          * This method initializes jButtonNewWeek     
          * @return javax.swing.JButton     
         private JButton getJButtonNewWeek() {
              if (jButtonNewWeek == null) {
                   jButtonNewWeek = new JButton();
                   jButtonNewWeek.setBounds(new Rectangle(270, 0, 91, 31));
                   jButtonNewWeek.setText("Ny Vecka");
                   jButtonNewWeek.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             System.out.println("actionPerformed()");
                             int i = getJTabbedPane().getSelectedIndex() + 1;
                             String tab = "Index: " + i;
                             getJTabbedPane().addTab(tab, new JLabel("Hello"));
                             getJTabbedPane().setSelectedIndex(getJTabbedPane().getTabCount()-1);
              return jButtonNewWeek;
          * This method initializes jButtonDelWeek     
          * @return javax.swing.JButton     
         private JButton getJButtonDelWeek() {
              if (jButtonDelWeek == null) {
                   jButtonDelWeek = new JButton();
                   jButtonDelWeek.setBounds(new Rectangle(375, 0, 121, 31));
                   jButtonDelWeek.setText("Ta bort vecka");
                   jButtonDelWeek.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             System.out.println("actionPerformed()");
                             getJTabbedPane().removeTabAt(getJTabbedPane().getSelectedIndex());
              return jButtonDelWeek;
          * @param args
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        Kinna thisClass = new Kinna();
                        thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        thisClass.setVisible(true);
          * This is the default constructor
         public Kinna() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setSize(670, 580);
              this.setContentPane(getJContentPane());
              this.setTitle("JFrame");
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.add(getJTabbedPane(), null);
                   jContentPane.add(getJButtonRed(), null);
                   jContentPane.add(getJButtonGreen(), null);
                   jContentPane.add(getJButtonBlue(), null);
                   jContentPane.add(getJButtonNewWeek(), null);
                   jContentPane.add(getJButtonDelWeek(), null);
              return jContentPane;
    }  //  @jve:decl-index=0:visual-constraint="29,25"

    If you have a different color for every cell in the table, then maybe it would be easier to store a custom Object in the TableModel that has two pieces of information:
    a) the text to be displayed
    b) the background color of the text.
    Then you can write a custom renderer that uses both pieces of information to renderer the cell correctly.
    Here is an untested example of what the custom renderer might look like:
    class ColorRenderer extends DefaultTableCellRenderer
         public Component getTableCellRendererComponent(
                   JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
              super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              CustomObject custom = (CustomObject)value;
              setText( custom.getText() );
              if (!isSelected)
                   setBackground( custom.getBackground() );
              return this;
    }

  • How to color a specific cell in ALV (not REUSE_ALV_GRID_DISPLAY)

    Hi
    I want to change color font or background to a specify position in ALV grid
    It is possible but by creating ALV container (not FM for example REUSE_ALV_GRID_DISPLAY)?

    Hi,
    REPORT ZALV_LIST1.
    TABLES:
    SPFLI.
    TYPE-POOLS:
    SLIS.
    PARAMETERS:
    P_COL TYPE I ,
    P_ROW TYPE I,
    P_COLOR(4) TYPE C .
    DATA:
    T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    FS_FIELDCAT LIKE LINE OF T_FIELDCAT,
    FS_LAYOUT TYPE SLIS_LAYOUT_ALV ,
    W_COLOR(4) ,
    W_ROW TYPE I,
    W_FIELDNAME(20),
    W_PROG TYPE SY-REPID.
    DATA:
    BEGIN OF T_SPFLI OCCURS 0,
    COLOR(4),
    CHECKBOX ,
    CELL TYPE SLIS_T_SPECIALCOL_ALV,
    CARRID TYPE SPFLI-CARRID,
    CONNID TYPE SPFLI-CONNID,
    CITYFROM TYPE SPFLI-CITYFROM,
    CITYTO TYPE SPFLI-CITYTO,
    DISTANCE TYPE SPFLI-DISTANCE,
    END OF T_SPFLI.
    DATA:
    FS_CELL LIKE LINE OF T_SPFLI-CELL.
    SELECT *
    FROM SPFLI
    INTO CORRESPONDING FIELDS OF TABLE T_SPFLI.
    W_COLOR = P_COLOR.
    T_SPFLI-COLOR = P_COLOR.
    IF P_COL IS INITIAL AND P_ROW GT 0.
    MODIFY T_SPFLI INDEX P_ROW TRANSPORTING COLOR.
    ENDIF.
    FS_FIELDCAT-FIELDNAME = 'CARRID'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 1.
    FS_FIELDCAT-KEY = 'X'.
    FS_FIELDCAT-HOTSPOT = 'X'.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    CLEAR FS_FIELDCAT .
    FS_FIELDCAT-FIELDNAME = 'CONNID'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 2.
    FS_FIELDCAT-KEY = 'X'.
    FS_FIELDCAT-HOTSPOT = 'X'.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    CLEAR FS_FIELDCAT .
    FS_FIELDCAT-FIELDNAME = 'DISTANCE'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 3.
    FS_FIELDCAT-KEY = ' '.
    FS_FIELDCAT-EDIT = 'X'.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    CLEAR FS_FIELDCAT.
    FS_FIELDCAT-FIELDNAME = 'CITYFROM'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 4.
    FS_FIELDCAT-KEY = ' '.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    LOOP AT T_FIELDCAT INTO FS_FIELDCAT.
    IF FS_FIELDCAT-COL_POS EQ P_COL.
    FS_FIELDCAT-EMPHASIZE = P_COLOR.
    W_FIELDNAME = FS_FIELDCAT-FIELDNAME.
    IF P_ROW IS INITIAL AND P_COL GT 0.
    MODIFY T_FIELDCAT FROM FS_FIELDCAT TRANSPORTING EMPHASIZE.
    ENDIF.
    ENDIF.
    ENDLOOP.
    FS_CELL-FIELDNAME = W_FIELDNAME .
    FS_CELL-COLOR-COL = 6.
    FS_CELL-NOKEYCOL = 'X'.
    APPEND FS_CELL TO T_SPFLI-CELL.
    IF P_ROW IS NOT INITIAL AND P_COL IS NOT INITIAL.
    MODIFY T_SPFLI INDEX P_ROW TRANSPORTING CELL.
    ENDIF.
    FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
    FS_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.
    FS_LAYOUT-COLTAB_FIELDNAME = 'CELL'.
    FS_LAYOUT-F2CODE = '&ETA'.
    W_PROG = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = W_PROG
    IS_LAYOUT = FS_LAYOUT
    IT_FIELDCAT = T_FIELDCAT
    TABLES
    T_OUTTAB = T_SPFLI
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2

  • Display Color for sigle  CELL in ALV report

    Hi all,
    I have one doubt is it possible to make a particular cell as read color in ALV.
    Ex: I have one field which shows amount in my ALV report,My requirement is that when ever the amount is less then 'ZERO', I have to show that particular cell in read color.
    Regards
    Anil Kumar.N

    hi,
    here code for coloring a perticular cell
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           marc.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
          werks LIKE marc-werks,
          mtart LIKE mara-mtart,
          matkl LIKE mara-matkl,
          meins LIKE mara-meins,
          ntgew LIKE mara-ntgew,
         rowcolor(4) TYPE c,
          cellcolors TYPE lvc_t_scol,
         END OF itab.
    DATA:t_fcat TYPE slis_t_fieldcat_alv,
         t_eve TYPE slis_t_event.
    DATA : st_layout TYPE slis_layout_alv.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr.  " no intervals no-extension.
    *PARAMETERS:mat LIKE mara-matnr.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cata USING t_fcat.
      PERFORM build_event.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM display_data.
    *&      Form  build_cata
          text
         -->TEMP_FCAT  text
    FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.
      sy-tvar0 = sy-uname.
      WRITE sy-datum TO sy-tvar1.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      wa_fcat-fix_column = 'x'.
      wa_fcat-key = 'X'.                                     "To color a column
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      wa_fcat-key = ' '.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MTART'.
      wa_fcat-seltext_m = 'Type'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATKL'.
      wa_fcat-seltext_m = 'Group'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MEINS'.
      wa_fcat-seltext_m = 'Measurement Unit'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'NTGEW'.
      wa_fcat-seltext_m = 'Net Value'.
      APPEND wa_fcat TO temp_fcat.
    ENDFORM.                    "build_cata
    *&      Form  build_event
          text
    FORM build_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_event
    *&      Form  data_retrieval
          text
    FORM data_retrieval.
      SELECT maramatnr  maramtart maramatkl marameins mara~ntgew
       maktmaktx  marcwerks
      INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt ON
      maramatnr = maktmatnr
      INNER JOIN marc ON
      maramatnr = marcmatnr
      WHERE mara~matnr IN mat.
      SORT itab BY matnr.
      DELETE ADJACENT DUPLICATES FROM itab.
    ENDFORM.                    "data_retrieval
    *&      Form  display_data
          text
    FORM display_data.
    *******************************For setting Cell Color*******************************************
      DATA ls_cellcolor TYPE lvc_s_scol .
      st_layout-coltab_fieldname = 'CELLCOLORS'.
      READ TABLE itab INDEX 5 .
      ls_cellcolor-fname = 'MATNR' .
      ls_cellcolor-color-col = '1' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO itab-cellcolors .
      MODIFY itab INDEX 5 .
    st_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = 'ZALV_DS'
          is_layout          = st_layout
          i_save             = 'A'
          it_fieldcat        = t_fcat
          it_events          = t_eve
        TABLES
          t_outtab           = itab
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_data
    Please reward if useful...

  • Different color text in one cell

    How do I set a color for a group of words within a cell leaving the rest of the words black?
    I can make all the text within a cell the same color but when I select the words I want to be a different color the color selector in the toolbar goes away and only fx, Cancel and Accept buttons are available.

    If it is simple text, not the result of a formula, select the words you want to change and select another color from the toolbar or the color panel. That is, unless I didn't understand your request. I don't know where you are seeing Accept, Cancel and Fx.

  • Displaying different colors for cells/columns in Interactive Report

    Hi,
    I have a requirement to display just the 'cells' in the Interactive Report columns with different colors.
    There are 3 columns in the Interactive report.
    The color coding for all the 3 different columns should be such that:
    <40% - red color
    40-70-orange
    greater than 70%-green
    I tried the highlight option in the report and saved the report as default, but still the color condition ended up getting displayed to the end user. I dont want this.
    Can someone suggest a better way to handle this requirement?

    Perhaps explore similar solutions described here
    Background Colour of Report Cell Issues.
    Scott

  • How to set two different UIE in one cell in ALV table

    Hi all,
    I have a hierachy ALV table. For some reason I want to have two UI elements in one column. For example, the text and a menu next to the text. Is it possiable to do that?
    best regards,
    Wenwen

    Hi,
    thank you for your answer. Yes, now I also find the class CL_SALV_WD_MULTI_CELL_EDITOR which could be used to set different UIE in one cell. But it is quite limited, just the following UIE could be used
    - LinkToAction 
    - LinkToURL    
    - FileDownload 
    - Button       
    - ToggleButton 
    best regards,
    Wenwen

  • Setting cell color in ALV

    Hi All
    I would be greatful if someone could please help...
    I am still attempting to get cells painted within a WDA ALV grid display.
    I have tried to use the method stated in the WDA sap press book - but this method is for use with TABLE element and I am using a ViewContainerUIElement for my table. There are mentions of wonderful ways to color cells in a list display - but I cannot understand how this can be achieved. I currently have this working appart from the numeric numbers of the design being set into the relavant column cell.
    If anyone could help that would be great...
    Please see: http://picasaweb.google.co.uk/dave.alexander69/Pictures#5244800978549492338
       LOOP AT lt_zdata INTO ls_zdata.
            lv_index = sy-tabix.
    *       set column values
    *       loop at row data and set colour attributes of individual cells
            LOOP AT lt_columns ASSIGNING <fs_column>.
              lr_col_header = <fs_column>-r_column->get_header( ).
              lr_col_header->set_ddic_binding_field( ).
              CREATE OBJECT lr_input_field EXPORTING value_fieldname = <fs_column>-id.
              lr_column = lr_column_settings->get_column( <fs_column>-id ).
    *         for the date columns only...
              IF <fs_column>-id(4) = 'CELL'.
    *           get and set column dates from select option user input
                READ TABLE lt_dates INTO ls_dates INDEX 1.
                IF lt_dates IS INITIAL.
                  lr_col_header->set_text( 'Date' ).
                ELSE.
                  ls_dates-low = ls_dates-low + lv_incr_date.
                  MOVE ls_dates-low+2(2) TO lv_for_col_date+6(2).   "Year
                  MOVE ls_dates-low+4(2) TO lv_for_col_date+3(2).   "Month
                  MOVE ls_dates-low+6(2) TO lv_for_col_date(2).     "Day
                  MOVE lv_for_col_date   TO lv_col_date.
                  lr_col_header->set_text( lv_col_date ).
                  lv_incr_date = lv_incr_date + 7.
                ENDIF.
                LOOP AT lt_orgdata_dates INTO ls_orgdata_dates
                  WHERE crew = ls_zdata-crew
                    AND position = ls_zdata-position
                    AND name = ls_zdata-person
                    AND trip_arr >= ls_dates-low
                    AND trip_dep <= ls_dates-low.
    *             column heading settings
                  lr_field = lr_table->if_salv_wd_field_settings~get_field( <fs_column>-id ).
                  lr_field->if_salv_wd_sort~set_sort_allowed( abap_false ).
    * trying to set cell variants ?@#??!!???
    *              lr_cv = lr_column->set_key( ls_zdata-variance ).
    *              lr_cv->set_editor( lr_input_field ).
    *              lr_cv->set_cell_design( value = '01').
    *              lr_column->add_cell_variant( lr_cv ).
    * current method of seeting the cell colors... (but puts value in cell!)
                  FIELD-SYMBOLS: <fs> TYPE data.
                  lr_column->set_cell_design_fieldname( value = <fs_column>-id ).
                  ASSIGN COMPONENT <fs_column>-id OF STRUCTURE ls_zdata TO <fs>.
                  WRITE: CL_WD_TABLE_COLUMN=>e_cell_design-one TO <fs>.
                  MODIFY lt_zdata FROM ls_zdata. " INDEX lv_index.
                ENDLOOP.
              ENDIF.
    Kind Regards
    Dave Alexander

    Hi check this code to set cell colors for ALV grid.
    Take a context attribute with type WDUI_TABLE_CELL_DESIGN.
    Here i am populating colors based on some condition.Check the loop of the internal table.
    method get_flight_details .
    data:node_flights type ref to if_wd_context_node,
         it_flights type sflight_tab1,
         ls_flights type sflight,
         it_final type   if_componentcontroller=>elements_flights,
         ls_final type   if_componentcontroller=>element_flights.
        select * from sflight into table it_flights
    up to 100 rows.
        node_flights = wd_context->get_child_node( 'FLIGHTS' ).
        loop at it_flights into ls_flights.
           move-corresponding ls_flights to ls_final.
           if ls_final-price = '185.00'.
              ls_final-readonly = abap_true.
              ls_final-celldesign =
    cl_wd_table_column=>e_cell_design-badvalue_light.
           else.
              ls_final-readonly = ' '.
              ls_final-celldesign =
    cl_wd_table_column=>e_cell_design-goodvalue_light.
           endif.
           append ls_final to it_final.
        endloop.
        node_flights->bind_table(
            new_items            = it_final
            set_initial_elements = abap_true
    *        INDEX                = INDEX
    data: l_ref_cmp_usage type ref to if_wd_component_usage.
    l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
    if l_ref_cmp_usage->has_active_component( ) is initial.
       l_ref_cmp_usage->create_component( ).
    endif.
    data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
    l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
       data:
         l_value type ref to cl_salv_wd_config_table.
       l_value = l_ref_interfacecontroller->get_model(
    * Make Price column editable
    data:l_column type ref to cl_salv_wd_column,
          l_column1 type ref to cl_salv_wd_column,
          lr_input type ref to cl_salv_wd_uie_input_field,
          l_input1 type ref to cl_salv_wd_uie_input_field.
    l_column = l_value->if_salv_wd_column_settings~get_column( 'PRICE' ).
    create object lr_input
      exporting
        value_fieldname = 'PRICE'
    l_column->set_cell_editor( value = lr_input ).
    * to make some cells non editable
    lr_input->set_read_only_fieldname( value = 'READONLY' ).
    l_value->if_salv_wd_column_settings~delete_column( id = 'READONLY'   )
    *Set the table Editable
    l_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).
    *Give colors to cells
    l_column1 = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).
    l_column1->set_cell_design_fieldname( value = 'CELLDESIGN'  ).
    l_value->if_salv_wd_column_settings~delete_column( id = 'CELLDESIGN' )
    endmethod.
    Thanks
    Suman

  • How to set different color text in JTabe cell

    Hi
    I have been searching many forums to find how can this be done, but no success.
    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells), CustomTableModel extends DefaultTableModel adding functionality for updateCellContent with different messages.
    I have a column in which cells i want to set these messages in different color.They are not set by user's editing, and by updating the content using the table model.
    Here is the code for that
    public void updateCellContent(HashMap<String, String> messages, int col) {
            for (int row = 0; row < this.dataVector.size() - 1; row++) {
                //This value is hardcoded for now.
                boolean isError = true;
                String filename = getFilename(row);
                String message = messages.get(filename);
                if (message != null) {
                    if (isError) {
                        setErrorMessage(message, row);
                    } else {
                        setMessage(message, row);
        private void setErrorMessage(String message, int row) {
            this.setFileStatus(message, row);
        private void setMessage(String message, int row) {
            String value = (String) this.getValueAt(row, COL_FILE_STATUS);
            ((Vector) this.dataVector.get(row)).setElementAt(value + " " + message, COL_FILE_STATUS);
            fireTableCellUpdated(row, COL_FILE_STATUS);
    public void setFileStatus(String message, int row) {
            setValueAt(message, row, COL_FILE_STATUS);
        }Thanks
    Dimitar

    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells)If I understand you correctly a better way to do this is to override the prepareRenderer(...) method of JTable. You can search the forum for my "Table Prepare Renderer" (without the spaces) example which shows how this can be done.
    I have a column in which cells i want to set these messages in different color.Then you need to use a custom renderer for that column.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • Is it possible to set a different color to part of a cell?

    Hi all,
    I am have trouble setting cell-specific Renderer.
    I have followed the instructions in the UISwing tutorial
    and extended JTable definition to overload getCellRenderer()
    to return myRenderer
    final JTable tableView = new JTable(dataModel){
    public TableCellRenderer getCellRenderer(int row, int column) {
    TableCellRenderer colorRenderer = new ColorRenderer();
    return(colorRenderer);
    My class definition for ColorRenderer is as follows:
    class ColorRenderer extends JLabel implements TableCellRenderer {
    public ColorRenderer() {
    public Component getTableCellRendererComponent(
    JTable table, Object color,
    boolean isSelected, boolean hasFocus,
    int row, int column) {
    setForeground(Color.blue);
    return this;
    Is it possible to set a different color to part of a cell?
    eg. I have "TEST,CELL,COLOR" as a string in a cell.
    Can I set a different color to the substring "CELL"?
    Your suggestions will be accepted most gratefully!
    Thanks in advance
    -Kalpana

    You should inherit your table cell renderer from a container, for example JPanel, add different JLabels to the panel and color them separately.
    Kurta

Maybe you are looking for

  • Building Criteria fail

    Adobe Bride CS5 is stuck in "Building Criteria". It won't finish and load thumbnails.

  • Special characters are not being displayed normally after recent update.

    FF messed up with that recent update. Special characters are now not being displayed properly - they somehow stretch the whole line where they are posted. It was fine before I.E.: http://www.discogs.com/artist/%E2%84%91%E2%8A%87%E2%89%A5%E2%97%8A%E2%

  • Netflix would change aspect ratio 30 seconds into the video.

    I'm having an issue with Netflix video streaming changing the aspect ratio from wide format to standard within 30 seconds into the video.  Doesn't happen on the sony PS3, macbook air, ipad2.  Any suggestions? Thanks in advance. Before: 30 Seconds int

  • Re: Help ! ADSL IP Profile Stuck at 2Mbps

    I am having the same issue but the contact me link is no longer working I am on a live chat with 1st line and she has run a line test and is now getting me to run a speed check dispite me already telling her I am geting 2Mbps rather than my ful poten

  • MsAccess connection

    I have created a MsAccess connection with SqlDeveloper 2.1.0.63, but when i tray the test i have this message: No Read Access to System Tables. Modify db before retrying. What are the parameters that i must change on Ms Access ? Help me please. Mario