diff --git a/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk index 643b6f1..c0f56b4 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_DATA_VALIDATION.slnk @@ -1,34 +1,59 @@ - + class ZCL_EXCEL_DATA_VALIDATION definition public final create public . +public section. *"* public components of class ZCL_EXCEL_DATA_VALIDATION *"* do not include other source files here!!! -public section. type-pools ABAP . + data ERRORSTYLE type ZEXCEL_DATA_VAL_ERROR_STYLE . + data OPERATOR type ZEXCEL_DATA_VAL_OPERATOR . data ALLOWBLANK type FLAG value 'X'. "#EC NOTEXT . data CELL_COLUMN type ZEXCEL_CELL_COLUMN_ALPHA . data CELL_COLUMN_TO type ZEXCEL_CELL_COLUMN_ALPHA . data CELL_ROW type ZEXCEL_CELL_ROW . data CELL_ROW_TO type ZEXCEL_CELL_ROW . - constants C_CUSTOM type ZEXCEL_DATA_VAL_TYPE value 'custom'. "#EC NOTEXT + constants C_TYPE_CUSTOM type ZEXCEL_DATA_VAL_TYPE value 'custom'. "#EC NOTEXT constants C_TYPE_LIST type ZEXCEL_DATA_VAL_TYPE value 'list'. "#EC NOTEXT data SHOWERRORMESSAGE type FLAG value 'X'. "#EC NOTEXT . data SHOWINPUTMESSAGE type FLAG value 'X'. "#EC NOTEXT . data TYPE type ZEXCEL_DATA_VAL_TYPE . - data VALUE type ZEXCEL_VALIDATION_FORMULA1 . + data FORMULA1 type ZEXCEL_VALIDATION_FORMULA1 . + data FORMULA2 type ZEXCEL_VALIDATION_FORMULA1 . + constants C_TYPE_NONE type ZEXCEL_DATA_VAL_TYPE value 'none'. "#EC NOTEXT + constants C_TYPE_DATE type ZEXCEL_DATA_VAL_TYPE value 'date'. "#EC NOTEXT + constants C_TYPE_DECIMAL type ZEXCEL_DATA_VAL_TYPE value 'decimal'. "#EC NOTEXT + constants C_TYPE_TEXTLENGTH type ZEXCEL_DATA_VAL_TYPE value 'textLength'. "#EC NOTEXT + constants C_TYPE_TIME type ZEXCEL_DATA_VAL_TYPE value 'time'. "#EC NOTEXT + constants C_TYPE_WHOLE type ZEXCEL_DATA_VAL_TYPE value 'whole'. "#EC NOTEXT + constants C_STYLE_STOP type ZEXCEL_DATA_VAL_ERROR_STYLE value 'stop'. "#EC NOTEXT + constants C_STYLE_WARNING type ZEXCEL_DATA_VAL_ERROR_STYLE value 'warning'. "#EC NOTEXT + constants C_STYLE_INFORMATION type ZEXCEL_DATA_VAL_ERROR_STYLE value 'information'. "#EC NOTEXT + constants C_OPERATOR_BETWEEN type ZEXCEL_DATA_VAL_OPERATOR value 'between'. "#EC NOTEXT + constants C_OPERATOR_EQUAL type ZEXCEL_DATA_VAL_OPERATOR value 'equal'. "#EC NOTEXT + constants C_OPERATOR_GREATERTHAN type ZEXCEL_DATA_VAL_OPERATOR value 'greaterThan'. "#EC NOTEXT + constants C_OPERATOR_GREATERTHANOREQUAL type ZEXCEL_DATA_VAL_OPERATOR value 'greaterThanOrEqual'. "#EC NOTEXT + constants C_OPERATOR_LESSTHAN type ZEXCEL_DATA_VAL_OPERATOR value 'lessThan'. "#EC NOTEXT + constants C_OPERATOR_LESSTHANOREQUAL type ZEXCEL_DATA_VAL_OPERATOR value 'lessThanOrEqual'. "#EC NOTEXT + constants C_OPERATOR_NOTBETWEEN type ZEXCEL_DATA_VAL_OPERATOR value 'notBetween'. "#EC NOTEXT + constants C_OPERATOR_NOTEQUAL type ZEXCEL_DATA_VAL_OPERATOR value 'notEqual'. "#EC NOTEXT + data SHOWDROPDOWN type FLAG . + data ERRORTITLE type STRING . + data ERROR type STRING . + data PROMPTTITLE type STRING . + data PROMPT type STRING . methods CONSTRUCTOR . *"* protected components of class ZCL_EXCEL_DATA_VALIDATION *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_DATA_VALIDATION -*"* do not include other source files here!!! -private section. + private section. +*"* private components of class ZCL_EXCEL_DATA_VALIDATION +*"* do not include other source files here!!! *"* local class implementation for public class *"* use this source file for the implementation part of *"* local helper classes @@ -37,26 +62,66 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class + + ABAP - - - - - - - - - - - - - method CONSTRUCTOR. - - type = me->c_type_list. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + METHOD constructor. + " Initialise instance variables + formula1 = ''. + formula2 = ''. + type = me->c_type_none. + errorstyle = me->c_style_stop. + operator = ''. + allowblank = abap_false. + showdropdown = abap_false. + showinputmessage = abap_true. + showerrormessage = abap_true. + errortitle = ''. + error = ''. + prompttitle = ''. + prompt = ''. * inizialize dimension range cell_row = 1. cell_column = 'A'. -endmethod. +ENDMETHOD. + diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 750786b..8db2fa4 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -1,6 +1,6 @@ - - + + class ZCL_EXCEL_WRITER_2007 definition public final @@ -112,32 +112,34 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + method ZIF_EXCEL_WRITER~WRITE_FILE. me->excel = io_excel. ep_file = me->create( ). endmethod. - - + + method CREATE. @@ -306,9 +308,10 @@ endmethod. ep_excel = lo_zip->save( ). endmethod. + - - + + method CREATE_CONTENT_TYPES. @@ -560,9 +563,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_DOCPROPS_APP. @@ -781,9 +785,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_DOCPROPS_CORE. @@ -897,9 +902,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_RELATIONSHIPS. @@ -996,10 +1002,11 @@ endmethod. lo_renderer->render( ). endmethod. + - - - + + + method CREATE_XL_DRAWINGS. @@ -1226,10 +1233,11 @@ endmethod. lo_renderer->render( ). endmethod. + - - - + + + method CREATE_XL_DRAWINGS_RELS. ** Constant node name @@ -1312,9 +1320,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_XL_RELATIONSHIPS. @@ -1460,9 +1469,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_XL_SHAREDSTRINGS. @@ -1577,12 +1587,13 @@ endmethod. lo_renderer->render( ). endmethod. + - - - - - method CREATE_XL_SHEET. + + + + + METHOD create_xl_sheet. ** Constant node name DATA: lc_xml_node_worksheet TYPE string VALUE 'worksheet', @@ -1613,6 +1624,7 @@ endmethod. lc_xml_node_datavalidations TYPE string VALUE 'dataValidations', lc_xml_node_datavalidation TYPE string VALUE 'dataValidation', lc_xml_node_formula1 TYPE string VALUE 'formula1', + lc_xml_node_formula2 TYPE string VALUE 'formula2', lc_xml_node_mergecell TYPE string VALUE 'mergeCell', lc_xml_node_mergecells TYPE string VALUE 'mergeCells', lc_xml_node_drawing TYPE string VALUE 'drawing', @@ -1679,6 +1691,10 @@ endmethod. lc_xml_attr_allowblank TYPE string VALUE 'allowBlank', lc_xml_attr_showinputmessage TYPE string VALUE 'showInputMessage', lc_xml_attr_showerrormessage TYPE string VALUE 'showErrorMessage', + lc_xml_attr_errortitle TYPE string VALUE 'errorTitle', + lc_xml_attr_error TYPE string VALUE 'error', + lc_xml_attr_prompttitle TYPE string VALUE 'promptTitle', + lc_xml_attr_prompt TYPE string VALUE 'prompt', lc_xml_attr_count TYPE string VALUE 'count', lc_xml_attr_blackandwhite TYPE string VALUE 'blackAndWhite', lc_xml_attr_cellcomments TYPE string VALUE 'cellComments', @@ -2390,6 +2406,9 @@ endmethod. lv_value = lo_data_validation->type. lo_element_2->set_attribute_ns( name = lc_xml_attr_type value = lv_value ). + lv_value = lo_data_validation->operator. + lo_element_2->set_attribute_ns( name = lc_xml_attr_operator + value = lv_value ). IF lo_data_validation->allowblank EQ abap_true. lv_value = '1'. ELSE. @@ -2411,6 +2430,26 @@ endmethod. ENDIF. lo_element_2->set_attribute_ns( name = lc_xml_attr_showerrormessage value = lv_value ). + IF NOT lo_data_validation->errortitle IS INITIAL. + lv_value = lo_data_validation->errortitle. + lo_element_2->set_attribute_ns( name = lc_xml_attr_errortitle + value = lv_value ). + ENDIF. + IF NOT lo_data_validation->error IS INITIAL. + lv_value = lo_data_validation->error. + lo_element_2->set_attribute_ns( name = lc_xml_attr_error + value = lv_value ). + ENDIF. + IF NOT lo_data_validation->prompttitle IS INITIAL. + lv_value = lo_data_validation->prompttitle. + lo_element_2->set_attribute_ns( name = lc_xml_attr_prompttitle + value = lv_value ). + ENDIF. + IF NOT lo_data_validation->prompt IS INITIAL. + lv_value = lo_data_validation->prompt. + lo_element_2->set_attribute_ns( name = lc_xml_attr_prompt + value = lv_value ). + ENDIF. lv_cell_row_s = lo_data_validation->cell_row. CONDENSE lv_cell_row_s. CONCATENATE lo_data_validation->cell_column lv_cell_row_s INTO lv_value. @@ -2424,10 +2463,19 @@ endmethod. " formula1 node lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula1 parent = lo_document ). - lv_value = lo_data_validation->value. + lv_value = lo_data_validation->formula1. lo_element_3->set_value( value = lv_value ). lo_element_2->append_child( new_child = lo_element_3 ). " formula1 node + " formula2 node + IF NOT lo_data_validation->formula2 IS INITIAL. + lo_element_3 = lo_document->create_simple_element( name = lc_xml_node_formula2 + parent = lo_document ). + lv_value = lo_data_validation->formula2. + lo_element_3->set_value( value = lv_value ). + + lo_element_2->append_child( new_child = lo_element_3 ). " formula2 node + ENDIF. lo_element->append_child( new_child = lo_element_2 ). " dataValidation node ENDWHILE. @@ -2707,12 +2755,13 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD. + - - - - + + + + method CREATE_XL_SHEET_RELS. @@ -2853,9 +2902,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_XL_STYLES. @@ -3588,10 +3638,11 @@ endmethod. lo_renderer->render( ). endmethod. + - - - + + + method CREATE_XL_TABLE. DATA: lc_xml_node_table TYPE string VALUE 'table', @@ -3759,9 +3810,10 @@ endmethod. lo_renderer->render( ). endmethod. + - - + + method CREATE_XL_THEME. @@ -3848,10 +3900,11 @@ endmethod. endmethod. + - - - METHOD create_xl_workbook. + + + method CREATE_XL_WORKBOOK. ** Constant node name @@ -4070,11 +4123,12 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -ENDMETHOD. +endmethod. + - - - + + + method FLAG2BOOL. @@ -4084,10 +4138,11 @@ ENDMETHOD. ep_boolean = 'false'. ENDIF. endmethod. + - - - + + + method GET_SHARED_STRING_INDEX. @@ -4097,5 +4152,6 @@ endmethod. ep_index = ls_shared_string-string_no. endmethod. + diff --git a/ZA2X/DTEL/ZEXCEL_DATA_VAL_ERROR_STYLE.slnk b/ZA2X/DTEL/ZEXCEL_DATA_VAL_ERROR_STYLE.slnk new file mode 100644 index 0000000..a24ea87 --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DATA_VAL_ERROR_STYLE.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/DTEL/ZEXCEL_DATA_VAL_OPERATOR.slnk b/ZA2X/DTEL/ZEXCEL_DATA_VAL_OPERATOR.slnk new file mode 100644 index 0000000..765fb4f --- /dev/null +++ b/ZA2X/DTEL/ZEXCEL_DATA_VAL_OPERATOR.slnk @@ -0,0 +1,4 @@ + + + + diff --git a/ZA2X/PROG/ZDEMO_EXCEL9.slnk b/ZA2X/PROG/ZDEMO_EXCEL9.slnk index d8d4453..df62adb 100644 --- a/ZA2X/PROG/ZDEMO_EXCEL9.slnk +++ b/ZA2X/PROG/ZDEMO_EXCEL9.slnk @@ -1,8 +1,8 @@ - + - + @@ -129,40 +129,69 @@ START-OF-SELECTION. ip_stop_row = 6 ). lo_worksheet = lo_excel->add_new_worksheet( ). - lv_title = 'Dropdown List'. + lv_title = 'Data Validations'. lo_worksheet->set_title( lv_title ). + " Maximum Text length + lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'Validate Maximum Text length of <= 10 in Cell A2:' ). + lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = 'abcdefghij' ). + lo_data_validation = lo_worksheet->add_new_data_validation( ). + lo_data_validation->type = zcl_excel_data_validation=>c_type_textlength. + lo_data_validation->operator = zcl_excel_data_validation=>c_operator_lessthanorequal. + lo_data_validation->formula1 = 10. + lo_data_validation->cell_row = 2. + lo_data_validation->cell_column = 'A'. + + " Integer Value between 1 and 10 + lo_worksheet->set_cell( ip_row = 4 ip_column = 'A' ip_value = 'Validate Integer Value between 1 and 10 in Cell A5:' ). + lo_worksheet->set_cell( ip_row = 5 ip_column = 'A' ip_value = '5' ). + lo_data_validation = lo_worksheet->add_new_data_validation( ). + lo_data_validation->type = zcl_excel_data_validation=>c_type_whole. + lo_data_validation->operator = zcl_excel_data_validation=>c_operator_between. + lo_data_validation->formula1 = 1. + lo_data_validation->formula2 = 10. + lo_data_validation->prompttitle = 'Range'. + lo_data_validation->prompt = 'Enter a value between 1 and 10'. + lo_data_validation->errortitle = 'Error'. + lo_data_validation->error = 'You have entered a wrong value. Please use only numbers between 1 and 10.'. + lo_data_validation->cell_row = 5. + lo_data_validation->cell_column = 'A'. + " There was an error when data validation was combined with cell merges this should test that: - lo_worksheet->set_cell( ip_row = 1 ip_column = 'A' ip_value = 'Demo for data validation with a dropdown list' ). - lo_worksheet->set_merge( ip_row = 1 ip_column_start = 'A' ip_column_end = 'F' ). + lo_worksheet->set_cell( ip_row = 10 ip_column = 'A' ip_value = 'Demo for data validation with a dropdown list' ). + lo_worksheet->set_merge( ip_row = 10 ip_column_start = 'A' ip_column_end = 'F' ). " Headlines - lo_worksheet->set_cell( ip_row = 2 ip_column = 'A' ip_value = c_fruits ). - lo_worksheet->set_cell( ip_row = 2 ip_column = 'B' ip_value = c_vegetables ). + lo_worksheet->set_cell( ip_row = 11 ip_column = 'A' ip_value = c_fruits ). + lo_worksheet->set_cell( ip_row = 11 ip_column = 'B' ip_value = c_vegetables ). - row = 3. - WHILE row < 14500. " Starting with 14500 the data validation is dropped 14000 are still ok + row = 12. + WHILE row < 20. " Starting with 14500 the data validation is dropped 14000 are still ok " 1st validation lo_data_validation = lo_worksheet->add_new_data_validation( ). - lo_data_validation->value = c_fruits. + lo_data_validation->type = zcl_excel_data_validation=>c_type_list. + lo_data_validation->formula1 = c_fruits. lo_data_validation->cell_row = row. lo_data_validation->cell_column = 'A'. lo_worksheet->set_cell( ip_row = row ip_column = 'A' ip_value = 'Select a value' ). - " 2nd + " 2nd lo_data_validation = lo_worksheet->add_new_data_validation( ). - lo_data_validation->value = c_vegetables. + lo_data_validation->type = zcl_excel_data_validation=>c_type_list. + lo_data_validation->formula1 = c_vegetables. lo_data_validation->cell_row = row. lo_data_validation->cell_column = 'B'. lo_worksheet->set_cell( ip_row = row ip_column = 'B' ip_value = 'Select a value' ). - " 3rd + " 3rd lo_data_validation = lo_worksheet->add_new_data_validation( ). - lo_data_validation->value = c_meat. + lo_data_validation->type = zcl_excel_data_validation=>c_type_list. + lo_data_validation->formula1 = c_meat. lo_data_validation->cell_row = row. lo_data_validation->cell_column = 'C'. lo_worksheet->set_cell( ip_row = row ip_column = 'C' ip_value = 'Select a value' ). - " 4th + " 4th lo_data_validation = lo_worksheet->add_new_data_validation( ). - lo_data_validation->value = c_fish. + lo_data_validation->type = zcl_excel_data_validation=>c_type_list. + lo_data_validation->formula1 = c_fish. lo_data_validation->cell_row = row. lo_data_validation->cell_column = 'D'. lo_worksheet->set_cell( ip_row = row ip_column = 'D' ip_value = 'Select a value' ).