From f05f72586241a9509c656fd9f77a730df503504f Mon Sep 17 00:00:00 2001 From: Rene Turnheim Date: Sun, 6 May 2012 22:17:37 +0000 Subject: [PATCH] issue #171 ready for testing; New method GET_DEFAULT_EXCEL_TIME_FORMAT created. git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@313 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk | 659 +++++++++++++++-------------- 1 file changed, 350 insertions(+), 309 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index 7530c49..f4976d2 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -1,8 +1,8 @@ - - - - + + + + class ZCL_EXCEL_WORKSHEET definition public final @@ -238,6 +238,9 @@ public section. methods GET_DEFAULT_EXCEL_DATE_FORMAT returning value(EP_DEFAULT_EXCEL_DATE_FORMAT) type ZEXCEL_NUMBER_FORMAT . + methods GET_DEFAULT_EXCEL_TIME_FORMAT + returning + value(EP_DEFAULT_EXCEL_TIME_FORMAT) type ZEXCEL_NUMBER_FORMAT . methods GET_DEFAULT_ROW_DIMENSION returning value(R_ROW_DIMENSION) type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . @@ -367,6 +370,7 @@ private section. data DATA_VALIDATIONS type ref to ZCL_EXCEL_DATA_VALIDATIONS . data DEFAULT_COLUMN_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_COLUMNDIME . data DEFAULT_EXCEL_DATE_FORMAT type ZEXCEL_NUMBER_FORMAT . + data DEFAULT_EXCEL_TIME_FORMAT type ZEXCEL_NUMBER_FORMAT . data DEFAULT_ROW_DIMENSION type ref to ZCL_EXCEL_WORKSHEET_ROWDIMENSI . data DRAWINGS type ref to ZCL_EXCEL_DRAWINGS . data EXCEL type ref to ZCL_EXCEL . @@ -566,38 +570,39 @@ endclass. ABAP SLIS SOI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method ZIF_EXCEL_SHEET_PROPERTIES~GET_STYLE. IF zif_excel_sheet_properties~style IS NOT INITIAL. @@ -662,35 +667,35 @@ endmethod. me->zif_excel_sheet_vba_project~codename_pr = ip_codename_pr. endmethod. - - + + method ADD_DRAWING. drawings->add( ip_drawing ). endmethod. - - + + method ADD_NEW_CONDITIONAL_STYLE. CREATE OBJECT eo_conditional_style. conditional_styles->add( eo_conditional_style ). endmethod. - - + + method ADD_NEW_DATA_VALIDATION. CREATE OBJECT eo_data_validation. data_validations->add( eo_data_validation ). endmethod. - - - - - - - + + + + + + + method BIND_ALV. data: lo_converter type ref to zcl_excel_converter. @@ -713,26 +718,26 @@ endmethod. endmethod. - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + method BIND_ALV_OLE2. *--------------------------------------------------------------------* * Method description: @@ -2302,8 +2307,8 @@ endmethod. set country space. * Hier wird nur die korrekte Kommaseparatierung gemacht, wenn die * Zeichen einer -* Zahl enthalten sind. Das ist f#ƒÂ#r Timestamps, die auch ":" enthalten. -* F#ƒÂ#r die +* Zahl enthalten sind. Das ist f#ƒÂ#r Timestamps, die auch ":" enthalten. +* F#ƒÂ#r die * darf keine Kommaseparierung stattfinden. * Changing for correction request - Y6BK041073 if contentsitem-value co '0123456789.,-+E '. @@ -2802,11 +2807,11 @@ endmethod. close_document. endmethod. - - - - - + + + + + method BIND_TABLE. DATA: @@ -2976,11 +2981,11 @@ endmethod. endmethod. - - - - - + + + + + method CALCULATE_CELL_WIDTH. DATA: cell_value TYPE zexcel_cell_value, guid TYPE zexcel_cell_style, @@ -3005,7 +3010,7 @@ endmethod. endmethod. - + method CALCULATE_COLUMN_WIDTHS. TYPES: BEGIN OF t_auto_size, @@ -3060,7 +3065,7 @@ endmethod. * ). * " For an easy start we just take the number of characters as the width * width = strlen( cell_value ). -* " Addition to solve issue #120, contribution by Stefan Schm#ƒÂ#cker +* " Addition to solve issue #120, contribution by Stefan Schm#ƒÂ#cker * " Calculate width using Font Size and Font Type * IF cell_style IS BOUND * AND cell_style->font IS BOUND. @@ -3083,107 +3088,107 @@ endmethod. endmethod. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + method CHANGE_CELL_STYLE. " issue # 139 DATA: stylemapping TYPE zexcel_s_stylemapping, @@ -3481,10 +3486,10 @@ endmethod. endmethod. - - - - + + + + method CONSTRUCTOR. DATA: lv_title TYPE zexcel_sheet_title. @@ -3526,7 +3531,7 @@ endmethod. endmethod. - + method DELETE_MERGE. DELETE sheet_content_merge INDEX 1. @@ -3534,10 +3539,10 @@ endmethod. endmethod. - - - - + + + + method FREEZE_PANES. data: lv_xsplit type i, lv_ysplit type i. @@ -3564,8 +3569,8 @@ endmethod. freeze_pane_cell_row = ip_num_rows + 1. endmethod. - - + + method GENERATE_TITLE. DATA: lo_worksheets_iterator TYPE REF TO cl_object_collection_iterator, lo_worksheet TYPE REF TO zcl_excel_worksheet, @@ -3599,8 +3604,8 @@ endmethod. ENDDO. endmethod. - - + + method GET_ACTIVE_CELL. DATA: lv_active_column TYPE zexcel_cell_column_alpha, @@ -3614,14 +3619,14 @@ endmethod. endmethod. - - - - - - - - + + + + + + + + method GET_CELL. DATA: lv_column TYPE zexcel_cell_column, @@ -3638,7 +3643,7 @@ endmethod. ep_value = ls_sheet_content-cell_value. ep_guid = ls_sheet_content-cell_style. " issue 139 - added this to be used for columnwidth calculation - " Addition to solve issue #120, contribution by Stefan Schm#ƒÂ#cker + " Addition to solve issue #120, contribution by Stefan Schm#ƒÂ#cker DATA: style_iterator TYPE REF TO cl_object_collection_iterator, style TYPE REF TO zcl_excel_style. IF ep_style IS REQUESTED. @@ -3653,10 +3658,10 @@ endmethod. ENDIF. endmethod. - - - - + + + + method GET_COLUMN_DIMENSION. FIELD-SYMBOLS: <fs_column_dimension> LIKE LINE OF column_dimensions. DATA: lv_column_alpha TYPE zexcel_cell_column_alpha. " issue #155 - less restrictive typing for ip_column @@ -3680,40 +3685,40 @@ endmethod. endmethod. - - + + method GET_COLUMN_DIMENSIONS. r_column_dimension[] = me->column_dimensions[]. endmethod. - - + + method GET_COND_STYLES_ITERATOR. eo_iterator = me->conditional_styles->get_iterator( ). endmethod. - - + + method GET_DATA_VALIDATIONS_ITERATOR. eo_iterator = me->data_validations->get_iterator( ). endmethod. - - + + method GET_DATA_VALIDATIONS_SIZE. ep_size = me->data_validations->size( ). endmethod. - - + + method GET_DEFAULT_COLUMN_DIMENSION. r_column_dimension = me->default_column_dimension. endmethod. - - + + method GET_DEFAULT_EXCEL_DATE_FORMAT. CONSTANTS: c_lang_e TYPE lang VALUE 'E'. @@ -3738,14 +3743,50 @@ endmethod. ep_default_excel_date_format = default_excel_date_format. endmethod. - - + + + METHOD get_default_excel_time_format. + DATA: l_timefm TYPE xutimefm. + + IF default_excel_time_format IS NOT INITIAL. + ep_default_excel_time_format = default_excel_time_format. + RETURN. + ENDIF. + +* Let's get default + l_timefm = cl_abap_timefm=>get_environment_timefm( ). + CASE l_timefm. + WHEN 0. +*0 24 Hour Format (Example: 12:05:10) + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time6. + WHEN 1. +*1 12 Hour Format (Example: 12:05:10 PM) + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. + WHEN 2. +*2 12 Hour Format (Example: 12:05:10 pm) for now all the same. no chnage upper lower + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. + WHEN 3. +*3 Hours from 0 to 11 (Example: 00:05:10 PM) for now all the same. no chnage upper lower + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. + WHEN 4. +*4 Hours from 0 to 11 (Example: 00:05:10 pm) for now all the same. no chnage upper lower + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time2. + WHEN OTHERS. + " and fallback to fixed format + default_excel_time_format = zcl_excel_style_number_format=>c_format_date_time6. + ENDCASE. + + ep_default_excel_time_format = default_excel_time_format. +ENDMETHOD. + + + method GET_DEFAULT_ROW_DIMENSION. r_row_dimension = me->default_row_dimension. endmethod. - - + + method GET_DIMENSION_RANGE. me->update_dimension_range( ). @@ -3763,62 +3804,62 @@ endmethod. endmethod. - - + + method GET_DRAWINGS. r_drawings = drawings. endmethod. - - + + method GET_DRAWINGS_ITERATOR. eo_iterator = drawings->get_iterator( ). endmethod. - - - + + + method GET_FREEZE_CELL. ep_row = me->freeze_pane_cell_row. ep_column = me->freeze_pane_cell_column. endmethod. - - + + method GET_GUID. ep_guid = me->guid. endmethod. - - + + method GET_HIGHEST_COLUMN. me->update_dimension_range( ). r_highest_column = me->lower_cell-cell_column. endmethod. - - + + method GET_HIGHEST_ROW. me->update_dimension_range( ). r_highest_row = me->lower_cell-cell_row. endmethod. - - + + method GET_HYPERLINKS_ITERATOR. eo_iterator = hyperlinks->get_iterator( ). endmethod. - - + + method GET_HYPERLINKS_SIZE. ep_size = hyperlinks->size( ). endmethod. - - + + method GET_MERGE. DATA: lv_column_start TYPE string, @@ -3892,9 +3933,9 @@ endmethod. endmethod. - - - + + + method GET_ROW_DIMENSION. FIELD-SYMBOLS: <fs_row_dimension> LIKE LINE OF row_dimensions. @@ -3914,27 +3955,27 @@ endmethod. endmethod. - - + + method GET_ROW_DIMENSIONS. r_row_dimension[] = me->row_dimensions[]. endmethod. - - + + method GET_TABLES_ITERATOR. eo_iterator = tables->if_object_collection~get_iterator( ). endmethod. - - + + method GET_TABLES_SIZE. ep_size = tables->if_object_collection~size( ). endmethod. - - - + + + method GET_TITLE. DATA lv_value TYPE string. IF ip_escaped EQ abap_true. @@ -3945,10 +3986,10 @@ endmethod. ENDIF. endmethod. - - - - + + + + method GET_VALUE_TYPE. DATA: lo_addit TYPE REF TO cl_abap_elemdescr, ls_dfies TYPE dfies, @@ -4002,16 +4043,16 @@ endmethod. endmethod. - - - - - - - - - - + + + + + + + + + + method SET_CELL. DATA: lv_column TYPE zexcel_cell_column, @@ -4223,11 +4264,11 @@ endmethod. endmethod. - - - - - + + + + + method SET_CELL_STYLE. DATA: lv_column TYPE zexcel_cell_column, @@ -4253,11 +4294,11 @@ endmethod. endmethod. - - - - - + + + + + method SET_COLUMN_WIDTH. DATA: column_dimension TYPE REF TO zcl_excel_worksheet_columndime. DATA: width TYPE float. @@ -4289,8 +4330,8 @@ endmethod. endmethod. - - + + method SET_DEFAULT_EXCEL_DATE_FORMAT. IF ip_default_excel_date_format IS INITIAL. @@ -4302,11 +4343,11 @@ endmethod. default_excel_date_format = ip_default_excel_date_format. endmethod. - - - - - + + + + + method SET_MERGE. DATA: lv_column_start TYPE zexcel_cell_column, @@ -4343,16 +4384,16 @@ endmethod. endmethod. - - + + method SET_PRINT_GRIDLINES. me->print_gridlines = i_print_gridlines. endmethod. - - - - + + + + method SET_ROW_HEIGHT. DATA: row_dimension TYPE REF TO zcl_excel_worksheet_rowdimensi. DATA: height TYPE float. @@ -4380,25 +4421,25 @@ endmethod. endmethod. - - + + method SET_SHOW_GRIDLINES. me->show_gridlines = i_show_gridlines. endmethod. - - + + method SET_SHOW_ROWCOLHEADERS. me->show_rowcolheaders = i_show_rowcolheaders. endmethod. - - - - - - - + + + + + + + method SET_TABLE. DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr, @@ -4455,9 +4496,9 @@ endmethod. endmethod. - - - + + + method SET_TITLE. DATA: lo_worksheets_iterator TYPE REF TO cl_object_collection_iterator, lo_worksheet TYPE REF TO zcl_excel_worksheet, @@ -4491,7 +4532,7 @@ endmethod. me->title = ip_title. endmethod. - + method UPDATE_DIMENSION_RANGE. DATA: ls_sheet_content TYPE zexcel_s_cell_data,