demos
demos copied to clipboard
ZDEMO_EXCEL9 Custom Data Validation in cell A8 doesn't seem to work
ZDEMO_EXCEL9
, all values entered in A8 are rejected, whatever B8 contains a "-" or not:
Details of the data validation in cell A8 (Custom, formula IF(B8<>"";INDIRECT(LEFT(B8;SEARCH("-";B8;1)));EMPTY)
):
Concerned ABAP code: https://github.com/abap2xlsx/demos/blob/2f89e63babc3590ea44773873b7b78db549f4c7b/src/zdemo_excel9.prog.abap#L130-L138
Indeed, there are 3 issues:
- First of all, a formula should start with
=
, which is currently not the case (starts withIF
). - In the ABAP code, the formula should always contains commas instead of semicolons, which is currently not the case. For information, the formulas in ABAP have to contain commas, but Excel will display them with semicolons for European people (Windows/Office settings set to European number formats) and commas are kept for US people.
- If I understand the intention (based on #159), it was to have the cell B8 contain a cell reference followed by
-
(the space was important) and the value in A8 should be equal to the value in that cell, e.g. if B8 containsA2 -
, A8 value could be onlyabcdefghij
. I propose to simplify that.
My proposal is to simplify the custom data validation formula, to validate that A8 starts with "T" if B8 contains a "-" and to not validate the input otherwise. Fix proposal:
- Change the text:
lo_worksheet->set_cell( ip_row = 7 ip_column = 'A' ip_value = 'Validate that A8 starts with "T" if B8 contains a "-":' ).
- Change the formula:
lo_data_validation->formula1 = '=IF(ISERROR(SEARCH("-",B8)),TRUE,LEFT(A8,1)="T")'.