
The separator between the arguments of a function is a comma, not a semicolon.Use only the english commands and not a localized version.The same things I found out for the formulas of the conditionl formatting applies also for the normal formulas in the cells. So I prefer the method with the fixed type table. If you use with type any you loose this kind of information and it is necessary to detect the data type additionally. But with the fixed type table method you know exactly the data types and this is for Excel very important, because numbers are right-aligned and strings are left aligned. Both cases have advantages and disadvantages. Lo_worksheet->set_cell( ip_column = 'A' ip_row = 1 ip_value = ls_data-my_field ).Īt last I decided to use the fixed type table method. On the other hand I use a fixed type table with a definitely structure: DATA: On the one hand, to be independent from the table type, I used field symbols and assign component command: FIELD-SYMBOLS:ĪSSIGN COMPONENT sy-index OF STRUCTURE TO. I use a method which copies the content row by row and field by field from the source to the target.
YES NO CONDITIONAL FORMATTING EXCEL 2016 ROW CODE
Today I wrote code to transfer data from an internal table to the Excel spreadsheet. You can find a very interesting online tool to translate formulas into different languages here. Delete the equal sign in front of the formula.If you copy the formula from the wizard, use only the english commands and not a localized version.When I have copied this formula in the ABAP code Excel told me, when opening the document, that it was damaged. To build the formula for the rule I use the Excel wizard.Īs you can see it creates the formula for the rule in a localized version. Lo_style_cond->mode_expression = ls_style_expr. Ls_style_expr-cell_style = lv_style_std_bold_red_guid. Ls_style_expr-formula = 'INDIRECT(ADDRESS(ROW(),COLUMN()))0'. Lo_style_cond->rule = zcl_excel_style_conditional=>c_rule_expression. Lo_style_cond = lo_worksheet->add_new_conditional_style( ). Lv_row = lo_worksheet->get_highest_row( ). Lv_style_std_bold_red_guid = lo_style_std_bold_red->get_guid( ). If the column contains 'No' or is blank not formatting shall be made (or earlier formatting should be erased if value earlier have been 'Yes'). If column T contains 'Yes' I would like the box (B2) to be colored in e.g blue with lines around it. Lo_style_std_bold_red->font->bold = abap_true. I have a box (cell) say on row B, cell 2. Lo_style_std_bold_red->font->scheme = zcl_excel_style_font=>c_scheme_none. Lo_style_std_bold_red->font->name = zcl_excel_style_font=>c_name_arial. Lo_style_std_bold_red = lo_excel->add_new_style( ). "-Create bold red font style based on standard for conditional formatting Ls_style_expr TYPE zexcel_conditional_expression Lo_style_cond TYPE REF TO zcl_excel_style_conditional, Lv_style_std_bold_red_guid TYPE zexcel_cell_style, Lo_style_std_bold_red TYPE REF TO zcl_excel_style, Today I wrote code with conditional formatting, here my ABAP code snippets as example. At the moment I write code for a project to generate of Excel reports via abap2xlsx and it works great.
