From 0ac55d2d3b3326aaed7204f674d7aa00b6605c91 Mon Sep 17 00:00:00 2001 From: Ivan Femia Date: Wed, 1 Jun 2011 19:14:52 +0000 Subject: [PATCH] better performance git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@192 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk | 11 +- ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk | 153 ++++++++++++++------ ZA2X/TABL/ZEXCEL_S_STYLES_COND_MAPPING.slnk | 7 + ZA2X/TTYP/ZEXCEL_T_STYLES_COND_MAPPING.slnk | 2 + 4 files changed, 129 insertions(+), 44 deletions(-) create mode 100644 ZA2X/TABL/ZEXCEL_S_STYLES_COND_MAPPING.slnk create mode 100644 ZA2X/TTYP/ZEXCEL_T_STYLES_COND_MAPPING.slnk diff --git a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk index 993fa0b..f6ce1b7 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WORKSHEET.slnk @@ -209,7 +209,10 @@ public section. !IP_TOP_LEFT_ROW type ZEXCEL_CELL_ROW default 3 . methods SET_TITLE importing - !IP_TITLE type ZEXCEL_SHEET_TITLE . + !IP_TITLE type ZEXCEL_SHEET_TITLE . + methods SET_SHOW_ROWCOLHEADERS + importing + !I_SHOW_ROWCOLHEADERS type ZEXCEL_SHOW_ROWCOLHEADER . *"* protected components of class ZCL_EXCEL_WORKSHEET *"* do not include other source files here!!! protected section. @@ -3409,6 +3412,12 @@ endmethod. method SET_SHOW_GRIDLINES. me->show_gridlines = i_show_gridlines. endmethod. + + + + METHOD set_show_rowcolheaders. + me->show_rowcolheaders = i_show_rowcolheaders. +ENDMETHOD. diff --git a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk index 2a39df2..581225e 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_WRITER_2007.slnk @@ -14,9 +14,9 @@ public section. *"* protected components of class ZCL_EXCEL_WRITER_2007 *"* do not include other source files here!!! protected section. - *"* private components of class ZCL_EXCEL_WRITER_2007 + private section. +*"* private components of class ZCL_EXCEL_WRITER_2007 *"* do not include other source files here!!! -private section. constants C_CONTENT_TYPES type STRING value '[Content_Types].xml'. "#EC NOTEXT constants C_DOCPROPS_APP type STRING value 'docProps/app.xml'. "#EC NOTEXT @@ -35,7 +35,7 @@ private section. constants C_XL_WORKBOOK type STRING value 'xl/workbook.xml'. "#EC NOTEXT data EXCEL type ref to ZCL_EXCEL . data SHARED_STRINGS type ZEXCEL_T_SHARED_STRING . - data STYLES_COND_MAPPING type ZEXCEL_T_STYLES_MAPPING . + data STYLES_COND_MAPPING type ZEXCEL_T_STYLES_COND_MAPPING . data STYLES_MAPPING type ZEXCEL_T_STYLES_MAPPING . methods CREATE @@ -136,7 +136,7 @@ private section. - + method ZIF_EXCEL_WRITER~WRITE_FILE. @@ -1766,7 +1766,7 @@ endmethod. lv_freeze_cell_column_alpha TYPE zexcel_cell_column_alpha, column_dimensions TYPE zexcel_t_worksheet_columndime, row_dimensions TYPE zexcel_t_worksheet_rowdimensio, - ls_style_cond_mapping TYPE zexcel_s_styles_mapping, + ls_style_cond_mapping TYPE zexcel_s_styles_cond_mapping, lv_relation_id TYPE i VALUE 0, outline_level_row TYPE i VALUE 0, outline_level_col TYPE i VALUE 0, @@ -2429,7 +2429,7 @@ endmethod. WHEN zcl_excel_style_conditional=>c_rule_cellis. ls_cellis = lo_style_conditional->mode_cellis. READ TABLE me->styles_cond_mapping INTO ls_style_cond_mapping WITH KEY guid = ls_cellis-cell_style. - lv_value = ls_style_cond_mapping-style. + lv_value = ls_style_cond_mapping-dxf. CONDENSE lv_value. lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid value = lv_value ). @@ -2445,7 +2445,7 @@ endmethod. WHEN zcl_excel_style_conditional=>c_rule_expression. ls_expression = lo_style_conditional->mode_expression. READ TABLE me->styles_cond_mapping INTO ls_style_cond_mapping WITH KEY guid = ls_expression-cell_style. - lv_value = ls_style_cond_mapping-style. + lv_value = ls_style_cond_mapping-dxf. CONDENSE lv_value. lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid value = lv_value ). @@ -2976,7 +2976,7 @@ endmethod. - method CREATE_XL_STYLES. + METHOD create_xl_styles. ** Constant node name @@ -3109,8 +3109,9 @@ endmethod. lt_cellxfs TYPE zexcel_t_cellxfs, ls_cellxfs TYPE zexcel_s_cellxfs, ls_styles_mapping TYPE zexcel_s_styles_mapping, - ls_style_cond_mapping TYPE zexcel_s_styles_mapping, - ls_cellis TYPE zexcel_conditional_cellis. + ls_style_cond_mapping TYPE zexcel_s_styles_cond_mapping, + ls_cellis TYPE zexcel_conditional_cellis, + ls_expression TYPE zexcel_conditional_expression. DATA: lv_value TYPE string, lv_dfx_count TYPE i, @@ -3713,43 +3714,109 @@ endmethod. READ TABLE lt_cellxfs INTO ls_cellxfs INDEX ls_styles_mapping-style. ADD 1 TO ls_cellxfs-fillid. " the numbering starts from 0 - ls_style_cond_mapping-guid = ls_cellis-cell_style. - ls_style_cond_mapping-style = lv_dfx_count. - APPEND ls_style_cond_mapping TO me->styles_cond_mapping. - ADD 1 TO lv_dfx_count. + " Style already mapped? + READ TABLE me->styles_cond_mapping INTO ls_style_cond_mapping WITH KEY style = ls_styles_mapping-style. + IF sy-subrc EQ 0. + ls_style_cond_mapping-guid = ls_cellis-cell_style. + APPEND ls_style_cond_mapping TO me->styles_cond_mapping. + ELSE. + ls_style_cond_mapping-guid = ls_cellis-cell_style. + ls_style_cond_mapping-style = ls_styles_mapping-style. + ls_style_cond_mapping-dxf = lv_dfx_count. + APPEND ls_style_cond_mapping TO me->styles_cond_mapping. + ADD 1 TO lv_dfx_count. - " dxf node - lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_dxf - parent = lo_document ). - - READ TABLE lt_fills INTO ls_fill INDEX ls_cellxfs-fillid. - IF ls_fill IS NOT INITIAL. - " fill properties - lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill - parent = lo_document ). - "pattern - lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_patternfill + " dxf node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_dxf parent = lo_document ). - lv_value = ls_fill-filltype. - lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_patterntype - value = lv_value ). - " fgcolor - create_xl_styles_color_node( - io_document = lo_document - io_parent = lo_sub_element_2 - is_color = ls_fill-fgcolor - iv_color_elem_name = lc_xml_node_fgcolor ). - " bgcolor - create_xl_styles_color_node( - io_document = lo_document - io_parent = lo_sub_element_2 - is_color = ls_fill-bgcolor - iv_color_elem_name = lc_xml_node_bgcolor ). + READ TABLE lt_fills INTO ls_fill INDEX ls_cellxfs-fillid. + IF ls_fill IS NOT INITIAL. + " fill properties + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element_2 + is_color = ls_fill-fgcolor + iv_color_elem_name = lc_xml_node_fgcolor ). - lo_element_fill->append_child( new_child = lo_sub_element_2 ). "pattern + " bgcolor + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element_2 + is_color = ls_fill-bgcolor + iv_color_elem_name = lc_xml_node_bgcolor ). - lo_sub_element->append_child( new_child = lo_element_fill ). + lo_element_fill->append_child( new_child = lo_sub_element_2 ). "pattern + + lo_sub_element->append_child( new_child = lo_element_fill ). + ENDIF. + ENDIF. + + lo_element->append_child( new_child = lo_sub_element ). + WHEN zcl_excel_style_conditional=>c_rule_expression. + "if style defined + ls_expression = lo_style_conditional->mode_expression. + IF ls_expression-cell_style IS INITIAL. + CONTINUE. + ENDIF. + READ TABLE me->styles_mapping INTO ls_styles_mapping WITH KEY guid = ls_expression-cell_style. + ADD 1 TO ls_styles_mapping-style. " the numbering starts from 0 + READ TABLE lt_cellxfs INTO ls_cellxfs INDEX ls_styles_mapping-style. + ADD 1 TO ls_cellxfs-fillid. " the numbering starts from 0 + + READ TABLE me->styles_cond_mapping INTO ls_style_cond_mapping WITH KEY style = ls_styles_mapping-style. + IF sy-subrc EQ 0. + ls_style_cond_mapping-guid = ls_expression-cell_style. + APPEND ls_style_cond_mapping TO me->styles_cond_mapping. + ELSE. + ls_style_cond_mapping-guid = ls_expression-cell_style. + ls_style_cond_mapping-style = ls_styles_mapping-style. + ls_style_cond_mapping-dxf = lv_dfx_count. + APPEND ls_style_cond_mapping TO me->styles_cond_mapping. + ADD 1 TO lv_dfx_count. + + " dxf node + lo_sub_element = lo_document->create_simple_element( name = lc_xml_node_dxf + parent = lo_document ). + + READ TABLE lt_fills INTO ls_fill INDEX ls_cellxfs-fillid. + IF ls_fill IS NOT INITIAL. + " fill properties + lo_element_fill = lo_document->create_simple_element( name = lc_xml_node_fill + parent = lo_document ). + "pattern + lo_sub_element_2 = lo_document->create_simple_element( name = lc_xml_node_patternfill + parent = lo_document ). + lv_value = ls_fill-filltype. + lo_sub_element_2->set_attribute_ns( name = lc_xml_attr_patterntype + value = lv_value ). + " fgcolor + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element_2 + is_color = ls_fill-fgcolor + iv_color_elem_name = lc_xml_node_fgcolor ). + + " bgcolor + create_xl_styles_color_node( + io_document = lo_document + io_parent = lo_sub_element_2 + is_color = ls_fill-bgcolor + iv_color_elem_name = lc_xml_node_bgcolor ). + + lo_element_fill->append_child( new_child = lo_sub_element_2 ). "pattern + + lo_sub_element->append_child( new_child = lo_element_fill ). + ENDIF. ENDIF. lo_element->append_child( new_child = lo_sub_element ). @@ -3783,7 +3850,7 @@ endmethod. lo_renderer = lo_ixml->create_renderer( ostream = lo_ostream document = lo_document ). lo_renderer->render( ). -endmethod. +ENDMETHOD. diff --git a/ZA2X/TABL/ZEXCEL_S_STYLES_COND_MAPPING.slnk b/ZA2X/TABL/ZEXCEL_S_STYLES_COND_MAPPING.slnk new file mode 100644 index 0000000..cad0477 --- /dev/null +++ b/ZA2X/TABL/ZEXCEL_S_STYLES_COND_MAPPING.slnk @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ZA2X/TTYP/ZEXCEL_T_STYLES_COND_MAPPING.slnk b/ZA2X/TTYP/ZEXCEL_T_STYLES_COND_MAPPING.slnk new file mode 100644 index 0000000..8a7d662 --- /dev/null +++ b/ZA2X/TTYP/ZEXCEL_T_STYLES_COND_MAPPING.slnk @@ -0,0 +1,2 @@ + +