diff --git a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk
index e30e08f..70a717e 100644
--- a/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk
+++ b/ZA2X/CLAS/ZCL_EXCEL_READER_2007.slnk
@@ -106,32 +106,32 @@
-
-
+
+ method ZIF_EXCEL_READER~CAN_READ_FILE.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-07
+* - Stefan Schmöcker, (done) 2012-11-07
* - ...
* changes: nothing done in code
* but started discussion about killing this method
*--------------------------------------------------------------------*
* For now always Unknown
r_readable = abap_undefined.
- endmethod.
+endmethod.
method ZIF_EXCEL_READER~LOAD.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Map Document Properties to ZCL_EXCEL
+* 2do§1 Map Document Properties to ZCL_EXCEL
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-07
+* - Stefan Schmöcker, (done) 2012-11-07
* - ...
* changes: renaming variables to naming conventions
* removing unused variables
@@ -141,7 +141,7 @@
* adding me-> where possible
*--------------------------------------------------------------------*
* issue#234 - error reading xlsx written by libre office
-* - Stefan Schmöcker, 2012-11-07
+* - Stefan Schmöcker, 2012-11-07
* changes: passing new optional input parameter to private attribute
*--------------------------------------------------------------------*
@@ -153,9 +153,9 @@
ls_relationship TYPE t_relationship.
*--------------------------------------------------------------------*
-* §1 Create EXCEL-Object we want to return to caller
+* §1 Create EXCEL-Object we want to return to caller
-* §2 We need to read the the file "\\_rels\.rels" because it tells
+* §2 We need to read the the file "\\_rels\.rels" because it tells
* us where in this folder structure the data for the workbook
* is located in the xlsx zip-archive
*
@@ -168,7 +168,7 @@
* |--> theme
* |--> worksheets
-* §3 Extracting from this the path&file where the workbook is located
+* §3 Extracting from this the path&file where the workbook is located
* Following is an example how this file could be set up
* <?xml version="1.0" encoding="UTF-8" standalone="true"?>
* <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
@@ -180,24 +180,24 @@
*--------------------------------------------------------------------*
-* §1 Create EXCEL-Object we want to return to caller
+* §1 Create EXCEL-Object we want to return to caller
*--------------------------------------------------------------------*
CREATE OBJECT r_excel.
*--------------------------------------------------------------------*
* issue#234 - error reading xlsx written by libre office
- me->zif_excel_reader~gv_use_alternate_zip = i_use_alternate_zip.
+ me->zif_excel_reader~gv_use_alternate_zip = iv_use_alternate_zip.
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
-* §2 Get file in folderstructure
+* §2 Get file in folderstructure
*--------------------------------------------------------------------*
me->excel2007 = i_excel2007.
lo_rels = me->get_ixml_from_zip_archive( '_rels/.rels' ).
*--------------------------------------------------------------------*
-* §3 Cycle through the Relationship Tags and use the ones we need
+* §3 Cycle through the Relationship Tags and use the ones we need
*--------------------------------------------------------------------*
lo_node ?= lo_rels->find_from_name( 'Relationship' ). "#EC NOTEXT
WHILE lo_node IS BOUND.
@@ -209,7 +209,7 @@
CASE ls_relationship-type.
WHEN lcv_core_properties.
- " 2do§1 Map Document Properties to ZCL_EXCEL
+ " 2do§1 Map Document Properties to ZCL_EXCEL
WHEN lcv_office_document.
me->load_workbook( iv_workbook_full_filename = ls_relationship-target
@@ -223,22 +223,22 @@
ENDWHILE.
- endmethod.
+endmethod.
- METHOD zif_excel_reader~load_file.
+ method ZIF_EXCEL_READER~LOAD_FILE.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 decision whether to load from frontend or backend
+* 2do§1 decision whether to load from frontend or backend
* current behavior ( autodecide ) should be default
* add optional parameter to allow user to choose
* to load from backend even when online
-* 2do§2 loosen typing of i_filename to CLIKE
+* 2do§2 loosen typing of i_filename to CLIKE
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-05
+* - Stefan Schmöcker, (done) 2012-11-05
* - ...
* changes: renaming variables to naming conventions
* renaming variables to indicate what they are used for
@@ -251,28 +251,130 @@
* added errorhandling for open dataset
*--------------------------------------------------------------------*
* issue#234 - error reading xlsx written by libre office
-* - Stefan Schmöcker, 2012-11-07
+* - Stefan Schmöcker, 2012-11-07
* changes: passing new optional input parameter to private attribute
*--------------------------------------------------------------------*
- DATA: lv_excel_data TYPE xstring.
+ CONSTANTS: lcv_load_from_frontend TYPE char1 VALUE 'F',
+ lcv_load_from_backend TYPE char1 VALUE 'B'.
-* issue#234 - error reading xlsx written by libre office
- me->zif_excel_reader~gv_use_alternate_zip = i_use_alternate_zip.
+ DATA: lv_load_from_source TYPE char1,
- IF i_from_applserver = abap_true.
- lv_excel_data = me->read_from_applserver( i_filename = i_filename ).
- ELSE.
- lv_excel_data = me->read_from_local_file( i_filename = i_filename ).
- ENDIF.
+ lv_filelength TYPE i,
+ lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY,
+ ls_binary_data LIKE LINE OF lt_binary_data,
+* Background processing
+ lv_max_length_line TYPE i,
+ lv_actual_length_line TYPE i,
+
+ lv_errormessage TYPE string, " Can't pass '...'(abc) to exception-class
+ lv_excel_data TYPE xstring. " Binary content of .xlsx file
+
+
+*--------------------------------------------------------------------*
+* ToDos: 2do§1 Decision whether to load from frontend or backend
+*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue#234 - error reading xlsx written by libre office
- r_excel = me->zif_excel_reader~load( i_excel2007 = lv_excel_data
- i_use_alternate_zip = i_use_alternate_zip ).
+ me->zif_excel_reader~gv_use_alternate_zip = iv_use_alternate_zip.
*--------------------------------------------------------------------*
- ENDMETHOD.
+
+*--------------------------------------------------------------------*
+* Autodecide on frontend or backend reading
+* Background-processing --> backend reading
+* Online-processing --> frontend reading
+*--------------------------------------------------------------------*
+ IF sy-batch = abap_true.
+ lv_load_from_source = lcv_load_from_backend.
+ ELSE.
+ lv_load_from_source = lcv_load_from_frontend.
+ ENDIF.
+
+ CASE lv_load_from_source.
+
+*--------------------------------------------------------------------*
+* Read from backend
+*--------------------------------------------------------------------*
+ WHEN lcv_load_from_backend.
+ DESCRIBE FIELD ls_binary_data LENGTH lv_max_length_line IN BYTE MODE.
+ OPEN DATASET i_filename FOR INPUT IN BINARY MODE.
+ IF sy-subrc <> 0.
+ lv_errormessage = 'A problem occured when reading the file'(001).
+ RAISE EXCEPTION TYPE zcx_excel
+ EXPORTING
+ error = lv_errormessage.
+ ENDIF.
+ WHILE sy-subrc = 0.
+
+ READ DATASET i_filename INTO ls_binary_data MAXIMUM LENGTH lv_max_length_line ACTUAL LENGTH lv_actual_length_line.
+ APPEND ls_binary_data TO lt_binary_data.
+ lv_filelength = lv_filelength + lv_actual_length_line.
+
+ ENDWHILE.
+ CLOSE DATASET i_filename.
+
+*--------------------------------------------------------------------*
+* Read from frontend
+*--------------------------------------------------------------------*
+ WHEN lcv_load_from_frontend.
+ cl_gui_frontend_services=>gui_upload( EXPORTING
+ filename = i_filename
+ filetype = 'BIN' " We are basically working with zipped directories --> force binary read
+ IMPORTING
+ filelength = lv_filelength
+ CHANGING
+ data_tab = lt_binary_data
+ EXCEPTIONS
+ file_open_error = 1
+ file_read_error = 2
+ no_batch = 3
+ gui_refuse_filetransfer = 4
+ invalid_type = 5
+ no_authority = 6
+ unknown_error = 7
+ bad_data_format = 8
+ header_not_allowed = 9
+ separator_not_allowed = 10
+ header_too_long = 11
+ unknown_dp_error = 12
+ access_denied = 13
+ dp_out_of_memory = 14
+ disk_full = 15
+ dp_timeout = 16
+ not_supported_by_gui = 17
+ error_no_gui = 18
+ OTHERS = 19 ).
+ IF sy-subrc <> 0.
+ lv_errormessage = 'A problem occured when reading the file'(001).
+ RAISE EXCEPTION TYPE zcx_excel
+ EXPORTING
+ error = lv_errormessage.
+ ENDIF.
+
+ ENDCASE.
+
+
+*--------------------------------------------------------------------*
+* Binary data needs to be provided as XSTRING for further processing
+*--------------------------------------------------------------------*
+ CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
+ EXPORTING
+ input_length = lv_filelength
+ IMPORTING
+ buffer = lv_excel_data
+ TABLES
+ binary_tab = lt_binary_data.
+
+*--------------------------------------------------------------------*
+* issue#234 - error reading xlsx written by libre office
+ r_excel = me->zif_excel_reader~load( i_excel2007 = lv_excel_data
+ iv_use_alternate_zip = iv_use_alternate_zip ).
+*--------------------------------------------------------------------*
+
+
+endmethod.
@@ -280,7 +382,7 @@
method FILL_STRUCT_FROM_ATTRIBUTES.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-07
+* - Stefan Schmöcker, (done) 2012-11-07
* - ...
* changes: renaming variables to naming conventions
* aligning code
@@ -323,7 +425,7 @@
ENDWHILE.
- endmethod.
+endmethod.
@@ -332,7 +434,7 @@
method GET_FROM_ZIP_ARCHIVE.
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-07
+* - Stefan Schmöcker, (done) 2012-11-07
* - ...
* changes: aligning code
* adding comments to explain what we are trying to achieve
@@ -340,7 +442,7 @@
* message made to support multilinguality
*--------------------------------------------------------------------**--------------------------------------------------------------------*
* issue#234 - error reading xlsx written by libre office
-* - Stefan Schmöcker, 2012-11-07
+* - Stefan Schmöcker, 2012-11-07
* changes: copying coding and using ALTERNATE_ZIP in ELSE-Branch
*--------------------------------------------------------------------*
@@ -449,7 +551,7 @@
* issue#234 - end of insertion
*--------------------------------------------------------------------*
- endmethod.
+endmethod.
@@ -459,12 +561,12 @@
method GET_IXML_FROM_ZIP_ARCHIVE.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Add comment what is being achieved here
+* 2do§1 Add comment what is being achieved here
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-07
+* - Stefan Schmöcker, (done) 2012-11-07
* - ...
* changes: renaming variables to naming conventions
* removing unnecessary type-pool
@@ -480,7 +582,7 @@
*--------------------------------------------------------------------*
-* 2do§1 ???? Something happens here ???
+* 2do§1 ???? Something happens here ???
*--------------------------------------------------------------------*
lv_content = me->get_from_zip_archive( i_filename ).
lo_ixml = cl_ixml=>create( ).
@@ -495,7 +597,7 @@
lo_parser->set_validating( mode = if_ixml_parser=>co_no_validation ).
lo_parser->parse( ).
- endmethod.
+endmethod.
@@ -647,7 +749,7 @@
lo_drawing->load_chart_attributes( rel_drawing-content_xml ).
endif.
- endmethod.
+endmethod.
@@ -655,12 +757,12 @@
method LOAD_SHARED_STRINGS.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Support partial formatting of strings in cells
+* 2do§1 Support partial formatting of strings in cells
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-11
+* - Stefan Schmöcker, (done) 2012-11-11
* - ...
* changes: renaming variables to naming conventions
* renaming variables to indicate what they are used for
@@ -683,10 +785,10 @@
*--------------------------------------------------------------------*
-* §1 Parse shared strings file and get into internal table
+* §1 Parse shared strings file and get into internal table
* So far I have encountered 2 ways how a string can be represented in the shared strings file
-* §1.1 - "simple" strings
-* §1.2 - rich text formatted strings
+* §1.1 - "simple" strings
+* §1.2 - rich text formatted strings
* Following is an example how this file could be set up; 2 strings in simple formatting, 3rd string rich textformatted
@@ -738,15 +840,15 @@
lv_tag_name = lo_node_si_child->get_name( ).
IF lv_tag_name = 't'.
*--------------------------------------------------------------------*
-* §1.1 - "simple" strings
+* §1.1 - "simple" strings
* Example: see above
*--------------------------------------------------------------------*
<lv_shared_string> = lo_node_si_child->get_value( ).
ELSE.
*--------------------------------------------------------------------*
-* §1.2 - rich text formatted strings
+* §1.2 - rich text formatted strings
* it is sufficient to strip the <t>...</t> tag from each <r>-tag and concatenate these
-* as long as rich text formatting is not supported (2do§1) ignore all info about formatting
+* as long as rich text formatting is not supported (2do§1) ignore all info about formatting
* Example: see above
*--------------------------------------------------------------------*
WHILE lo_node_si_child IS BOUND. " actually these children of <si> are <r>-tags
@@ -766,7 +868,7 @@
lo_node_si ?= lo_node_si->get_next( ).
ENDWHILE.
- endmethod.
+endmethod.
@@ -776,7 +878,7 @@
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (wip ) 2012-11-25
+* - Stefan Schmöcker, (wip ) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
@@ -844,16 +946,16 @@
*--------------------------------------------------------------------*
* To build a complete style that fully describes how a cell looks like
* we need the various parts
-* §1 - Numberformat
-* §2 - Fillstyle
-* §3 - Borders
-* §4 - Font
-* §5 - Alignment
-* §6 - Protection
+* §1 - Numberformat
+* §2 - Fillstyle
+* §3 - Borders
+* §4 - Font
+* §5 - Alignment
+* §6 - Protection
* Following is an example how this part of a file could be set up
* ...
-* parts with various formatinformation - see §1,§2,§3,§4
+* parts with various formatinformation - see §1,§2,§3,§4
* ...
* <cellXfs count="26">
* <xf numFmtId="0" borderId="0" fillId="0" fontId="0" xfId="0"/>
@@ -871,17 +973,17 @@
*--------------------------------------------------------------------*
* The styles are build up from
-* §1 number formats
-* §2 fill styles
-* §3 border styles
-* §4 fonts
+* §1 number formats
+* §2 fill styles
+* §3 border styles
+* §4 fonts
* These need to be read before we can try to build up a complete
* style that describes the look of a cell
*--------------------------------------------------------------------*
- lt_num_formats = load_style_num_formats( lo_styles_xml ). " §1
- lt_fills = load_style_fills( lo_styles_xml ). " §2
- lt_borders = load_style_borders( lo_styles_xml ). " §3
- lt_fonts = load_style_fonts( lo_styles_xml ). " §4
+ lt_num_formats = load_style_num_formats( lo_styles_xml ). " §1
+ lt_fills = load_style_fills( lo_styles_xml ). " §2
+ lt_borders = load_style_borders( lo_styles_xml ). " §3
+ lt_fonts = load_style_fonts( lo_styles_xml ). " §4
*--------------------------------------------------------------------*
* Now everything is prepared to build a "full" style
@@ -899,7 +1001,7 @@
CHANGING
cp_structure = ls_xf ).
*--------------------------------------------------------------------*
-* §2 fill style
+* §2 fill style
*--------------------------------------------------------------------*
IF ls_xf-applyfill = '1' AND ls_xf-fillid IS NOT INITIAL.
lv_index = ls_xf-fillid + 1.
@@ -910,7 +1012,7 @@
ENDIF.
*--------------------------------------------------------------------*
-* §1 number format
+* §1 number format
*--------------------------------------------------------------------*
IF ls_xf-numfmtid IS NOT INITIAL.
READ TABLE lt_num_formats INTO ls_num_format WITH TABLE KEY id = ls_xf-numfmtid.
@@ -920,7 +1022,7 @@
ENDIF.
*--------------------------------------------------------------------*
-* §3 border style
+* §3 border style
*--------------------------------------------------------------------*
IF ls_xf-applyborder = '1' AND ls_xf-borderid IS NOT INITIAL.
lv_index = ls_xf-borderid + 1.
@@ -931,7 +1033,7 @@
ENDIF.
*--------------------------------------------------------------------*
-* §4 font
+* §4 font
*--------------------------------------------------------------------*
IF ls_xf-applyfont = '1' AND ls_xf-fontid IS NOT INITIAL.
lv_index = ls_xf-fontid + 1.
@@ -942,7 +1044,7 @@
ENDIF.
*--------------------------------------------------------------------*
-* §5 - Alignment
+* §5 - Alignment
*--------------------------------------------------------------------*
lo_node_cellxfs_xf_alignment ?= lo_node_cellxfs_xf->find_from_name( 'alignment' ).
IF lo_node_cellxfs_xf_alignment IS BOUND.
@@ -976,7 +1078,7 @@
ENDIF.
*--------------------------------------------------------------------*
-* §6 - Protection
+* §6 - Protection
*--------------------------------------------------------------------*
lo_node_cellxfs_xf_protection ?= lo_node_cellxfs_xf->find_from_name( 'protection' ).
IF lo_node_cellxfs_xf_protection IS BOUND.
@@ -1005,7 +1107,7 @@
ENDWHILE.
ENDIF.
- endmethod.
+endmethod.
@@ -1014,7 +1116,7 @@
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-25
+* - Stefan Schmöcker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
@@ -1030,11 +1132,11 @@
*--------------------------------------------------------------------*
* We need a table of used borderformats to build up our styles
-* §1 A cell has 4 outer borders and 2 diagonal "borders"
+* §1 A cell has 4 outer borders and 2 diagonal "borders"
* These borders can be formatted separately but the diagonal borders
* are always being formatted the same
* We'll parse through the <border>-tag for each of the bordertypes
-* §2 and read the corresponding formatting information
+* §2 and read the corresponding formatting information
* Following is an example how this part of a file could be set up
* <border diagonalDown="1">
@@ -1077,7 +1179,7 @@
lo_node_bordertype ?= lo_node_border->get_first_child( ).
WHILE lo_node_bordertype IS BOUND.
*--------------------------------------------------------------------*
-* §1 Determine what kind of border we are talking about
+* §1 Determine what kind of border we are talking about
*--------------------------------------------------------------------*
* Up, down, left, right, diagonal
*--------------------------------------------------------------------*
@@ -1103,7 +1205,7 @@
ENDCASE.
*--------------------------------------------------------------------*
-* §2 Read the border-formatting
+* §2 Read the border-formatting
*--------------------------------------------------------------------*
lo_border->border_style = lo_node_bordertype->get_attribute( 'style' ).
lo_node_bordercolor ?= lo_node_bordertype->find_from_name( 'color' ).
@@ -1135,7 +1237,7 @@
ENDWHILE.
- endmethod.
+endmethod.
@@ -1143,12 +1245,12 @@
method LOAD_STYLE_FILLS.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Support gradientFill
+* 2do§1 Support gradientFill
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-25
+* - Stefan Schmöcker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
@@ -1239,7 +1341,7 @@
* gradientFill
*--------------------------------------------------------------------*
WHEN 'gradientFill'.
- " 2do§1 Support gradientFill
+ " 2do§1 Support gradientFill
WHEN OTHERS.
@@ -1253,7 +1355,7 @@
ENDWHILE.
- endmethod.
+endmethod.
@@ -1262,7 +1364,7 @@
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-25
+* - Stefan Schmöcker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* aligning code
@@ -1379,7 +1481,7 @@
ENDWHILE.
- endmethod.
+endmethod.
@@ -1387,12 +1489,12 @@
method LOAD_STYLE_NUM_FORMATS.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Explain gaps in predefined formats
+* 2do§1 Explain gaps in predefined formats
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-25
+* - Stefan Schmöcker, (done) 2012-11-25
* - ...
* changes: renaming variables and types to naming conventions
* adding comments to explain what we are trying to achieve
@@ -1404,12 +1506,12 @@
*--------------------------------------------------------------------*
* We need a table of used numberformats to build up our styles
* there are two kinds of numberformats
-* §1 those that have been explicitly added by the createor of the excel-file
-* §2 and built-in numberformats
+* §1 those that have been explicitly added by the createor of the excel-file
+* §2 and built-in numberformats
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
-* §1 Get non-internal numberformats that are found in the file explicitly
+* §1 Get non-internal numberformats that are found in the file explicitly
* Following is an example how this part of a file could be set up
* <numFmts count="1">
@@ -1438,7 +1540,7 @@
END-OF-DEFINITION.
*--------------------------------------------------------------------*
-* §1 Get internal predefined numberformats
+* §1 Get internal predefined numberformats
*--------------------------------------------------------------------*
predefined_format '1' '0'.
predefined_format '2' '0.00'.
@@ -1462,7 +1564,7 @@
predefined_format '20' 'h:mm'.
predefined_format '21' 'h:mm:ss'.
predefined_format '22' 'm/d/yyyy h:mm'.
-* 2do§1 Why is there a gap in here?
+* 2do§1 Why is there a gap in here?
@@ -1480,7 +1582,7 @@
predefined_format '38' '#,##0_);[Red](#,##0)'.
predefined_format '39' '#,##0.00_);(#,##0.00)'.
predefined_format '40' '#,##0.00_);[Red](#,##0.00)'.
-* 2do§1 Why is there a gap in here?
+* 2do§1 Why is there a gap in here?
@@ -1489,26 +1591,26 @@
predefined_format '47' 'mm:ss.0'.
predefined_format '48' '##0.0E+0'.
predefined_format '49' '@'.
-* 2do§1 Is 49 really the last predefined format?
+* 2do§1 Is 49 really the last predefined format?
- endmethod.
+endmethod.
- method LOAD_WORKBOOK.
+ METHOD load_workbook.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Move macro-reading from zcl_excel_reader_xlsm to this class
+* 2do§1 Move macro-reading from zcl_excel_reader_xlsm to this class
* autodetect existance of macro/vba content
* Allow inputparameter to explicitly tell reader to ignore vba-content
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-10
+* - Stefan Schmöcker, (done) 2012-11-10
* - ...
* changes: renaming variables to naming conventions
* aligning code
@@ -1520,15 +1622,15 @@
* ip_excel renamed while being at it --> rename to io_excel
*--------------------------------------------------------------------*
* issue #232 - Read worksheetstate hidden/veryHidden
-* - Stefan Schmöcker, 2012-11-11
+* - Stefan Schmöcker, 2012-11-11
*--------------------------------------------------------------------*
* issue#235 - repeat rows/columns
-* - Stefan Schmöcker, 2012-12-02
+* - Stefan Schmöcker, 2012-12-02
* changes: correction in named ranges to correctly attach
* sheetlocal names/ranges to the correct sheet
*--------------------------------------------------------------------*
* issue#284 - Copied formulae ignored when reading excelfile
-* - Stefan Schmöcker, 2013-08-02
+* - Stefan Schmöcker, 2013-08-02
* changes: initialize area to hold referenced formulaedata
* after all worksheets have been read resolve formuae
*--------------------------------------------------------------------*
@@ -1591,7 +1693,7 @@
*--------------------------------------------------------------------*
-* §1 Get the position of files related to this workbook
+* §1 Get the position of files related to this workbook
* Usually this will be <root>/xl/workbook.xml
* Thus the workbookroot will be <root>/xl/
* The position of all related files will be given in file
@@ -1611,19 +1713,19 @@
* <Relationship Target="sharedStrings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Id="rId7"/>
* </Relationships>
*
-* §2 Load data that is relevant to the complete workbook
+* §2 Load data that is relevant to the complete workbook
* Currently supported is:
-* §2.1 Shared strings - This holds all strings that are used in all worksheets
-* §2.2 Styles - This holds all styles that are used in all worksheets
-* §2.3 Worksheets - For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet
-* §2.4 [Themes] - not supported
-* §2.5 [VBA (Macro)] - supported in class zcl_excel_reader_xlsm but should be moved here and autodetect
+* §2.1 Shared strings - This holds all strings that are used in all worksheets
+* §2.2 Styles - This holds all styles that are used in all worksheets
+* §2.3 Worksheets - For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet
+* §2.4 [Themes] - not supported
+* §2.5 [VBA (Macro)] - supported in class zcl_excel_reader_xlsm but should be moved here and autodetect
* ...
*
-* §3 Some information is held in the workbookfile as well
-* §3.1 Names and order of of worksheets
-* §3.2 Active worksheet
-* §3.3 Defined names
+* §3 Some information is held in the workbookfile as well
+* §3.1 Names and order of of worksheets
+* §3.2 Active worksheet
+* §3.3 Defined names
* ...
* Following is an example how this file could be set up
@@ -1648,7 +1750,7 @@
CLEAR me->mt_ref_formulae. " ins issue#284
*--------------------------------------------------------------------*
-* §1 Get the position of files related to this workbook
+* §1 Get the position of files related to this workbook
* Entry into this method is with the filename of the workbook
*--------------------------------------------------------------------*
CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
@@ -1670,7 +1772,7 @@
CASE ls_relationship-type.
*--------------------------------------------------------------------*
-* §2.1 Shared strings - This holds all strings that are used in all worksheets
+* §2.1 Shared strings - This holds all strings that are used in all worksheets
*--------------------------------------------------------------------*
WHEN lcv_shared_strings.
CONCATENATE lv_path ls_relationship-target
@@ -1678,7 +1780,7 @@
me->load_shared_strings( lv_full_filename ).
*--------------------------------------------------------------------*
-* §2.3 Worksheets
+* §2.3 Worksheets
* For each worksheet in the workbook one entry appears here to point to the file that holds the content of this worksheet
* Shared strings and styles have to be present before we can start with creating the worksheets
* thus we only store this information for use when parsing the workbookfile for sheetinformations
@@ -1687,7 +1789,7 @@
APPEND ls_relationship TO lt_worksheets.
*--------------------------------------------------------------------*
-* §2.2 Styles - This holds the styles that are used in all worksheets
+* §2.2 Styles - This holds the styles that are used in all worksheets
*--------------------------------------------------------------------*
WHEN lcv_styles.
CONCATENATE lv_path ls_relationship-target
@@ -1704,12 +1806,12 @@
ENDWHILE.
*--------------------------------------------------------------------*
-* §3 Some information held in the workbookfile
+* §3 Some information held in the workbookfile
*--------------------------------------------------------------------*
lo_workbook = me->get_ixml_from_zip_archive( iv_workbook_full_filename ).
*--------------------------------------------------------------------*
-* §3.1 Names and order of of worksheets
+* §3.1 Names and order of of worksheets
*--------------------------------------------------------------------*
lo_node ?= lo_workbook->find_from_name( 'sheet' ).
lv_workbook_index = 1.
@@ -1772,7 +1874,7 @@
" ins issue#284
*--------------------------------------------------------------------*
* #229: Set active worksheet - begin coding
-* §3.2 Active worksheet
+* §3.2 Active worksheet
*--------------------------------------------------------------------*
lv_zexcel_active_worksheet = 1. " First sheet = active sheet if nothing else specified.
lo_node ?= lo_workbook->find_from_name( 'workbookView' ).
@@ -1790,7 +1892,7 @@
*--------------------------------------------------------------------*
-* §3.3 Defined names
+* §3.3 Defined names
* So far I have encountered these
* - named ranges - sheetlocal
* - named ranges - workbookglobal
@@ -1911,16 +2013,16 @@
ENDWHILE.
- endmethod.
+ENDMETHOD.
- method LOAD_WORKSHEET.
+ METHOD load_worksheet.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Header/footer
+* 2do§1 Header/footer
*
* Please don't just delete these ToDos if they are not
* needed but leave a comment that states this
@@ -1928,7 +2030,7 @@
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker,
+* - Stefan Schmöcker,
* - ...
* changes: renaming variables to naming conventions
* aligning code (started)
@@ -2010,6 +2112,27 @@
theme TYPE string,
END OF lty_tabcolor.
+ TYPES: BEGIN OF lty_datavalidation,
+ type TYPE zexcel_data_val_type,
+ allowblank TYPE flag,
+ showinputmessage TYPE flag,
+ showerrormessage TYPE flag,
+ showdropdown TYPE flag,
+ operator TYPE zexcel_data_val_operator,
+ formula1 TYPE zexcel_validation_formula1,
+ formula2 TYPE zexcel_validation_formula1,
+ sqref TYPE string,
+ cell_column TYPE zexcel_cell_column_alpha,
+ cell_column_to TYPE zexcel_cell_column_alpha,
+ cell_row TYPE zexcel_cell_row,
+ cell_row_to TYPE zexcel_cell_row,
+ error TYPE string,
+ errortitle TYPE string,
+ prompt TYPE string,
+ prompttitle TYPE string,
+ errorstyle TYPE zexcel_data_val_error_style,
+ END OF lty_datavalidation.
+
CONSTANTS: lc_xml_attr_true TYPE string VALUE 'true',
lc_xml_attr_true_int TYPE string VALUE '1',
@@ -2095,11 +2218,18 @@
lo_ixml_rels_worksheet TYPE REF TO if_ixml_document,
lv_rels_worksheet_path TYPE string,
lv_stripped_name TYPE chkfile,
- lv_dirname TYPE string.
+ lv_dirname TYPE string,
+
+ lo_ixml_datavalidations TYPE REF TO if_ixml_node_collection,
+ lo_ixml_datavalidation_elem TYPE REF TO if_ixml_element,
+ ls_datavalidation TYPE lty_datavalidation,
+ lo_data_validation TYPE REF TO zcl_excel_data_validation,
+ lv_datavalidation_range TYPE string,
+ lt_datavalidation_range TYPE TABLE OF string.
*--------------------------------------------------------------------*
-* §2 We need to read the the file "\\_rels\.rels" because it tells
+* §2 We need to read the the file "\\_rels\.rels" because it tells
* us where in this folder structure the data for the workbook
* is located in the xlsx zip-archive
*
@@ -2498,7 +2628,7 @@
ls_odd_footer-left_value = lo_ixml_hf_value_elem->get_value( ).
ENDIF.
-* 2do§1 Header/footer
+* 2do§1 Header/footer
" TODO.. get the rest.
io_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_odd_header
@@ -2535,7 +2665,59 @@
ENDIF.
" End fix 194 Read attributes HIDDEN, OUTLINELEVEL, COLLAPSED in ZCL_EXCEL_READER_2007
- endmethod.
+ " Start fix 276 Read data validations
+ "Add merge cell information
+ lo_ixml_datavalidations = lo_ixml_worksheet->get_elements_by_tag_name( name = 'dataValidation' ).
+ lo_ixml_iterator = lo_ixml_datavalidations->create_iterator( ).
+ lo_ixml_datavalidation_elem ?= lo_ixml_iterator->get_next( ).
+ WHILE lo_ixml_datavalidation_elem IS BOUND.
+ fill_struct_from_attributes( EXPORTING
+ ip_element = lo_ixml_datavalidation_elem
+ CHANGING
+ cp_structure = ls_datavalidation ).
+ clear lo_ixml_formula_elem.
+ lo_ixml_formula_elem = lo_ixml_datavalidation_elem->find_from_name( name = 'formula1' ).
+ if lo_ixml_formula_elem is bound.
+ ls_datavalidation-formula1 = lo_ixml_formula_elem->get_value( ).
+ endif.
+ clear lo_ixml_formula_elem.
+ lo_ixml_formula_elem = lo_ixml_datavalidation_elem->find_from_name( name = 'formula2' ).
+ if lo_ixml_formula_elem is bound.
+ ls_datavalidation-formula2 = lo_ixml_formula_elem->get_value( ).
+ endif.
+ SPLIT ls_datavalidation-sqref AT space INTO TABLE lt_datavalidation_range.
+ LOOP AT lt_datavalidation_range INTO lv_datavalidation_range.
+ zcl_excel_common=>convert_range2column_a_row( EXPORTING
+ i_range = lv_datavalidation_range
+ IMPORTING
+ e_column_start = ls_datavalidation-cell_column
+ e_column_end = ls_datavalidation-cell_column_to
+ e_row_start = ls_datavalidation-cell_row
+ e_row_end = ls_datavalidation-cell_row_to ).
+ lo_data_validation = io_worksheet->add_new_data_validation( ).
+ lo_data_validation->type = ls_datavalidation-type.
+ lo_data_validation->allowblank = ls_datavalidation-allowblank.
+ lo_data_validation->showinputmessage = ls_datavalidation-showinputmessage.
+ lo_data_validation->showerrormessage = ls_datavalidation-showerrormessage.
+ lo_data_validation->showdropdown = ls_datavalidation-showdropdown.
+ lo_data_validation->operator = ls_datavalidation-operator.
+ lo_data_validation->formula1 = ls_datavalidation-formula1.
+ lo_data_validation->formula2 = ls_datavalidation-formula2.
+ lo_data_validation->prompttitle = ls_datavalidation-prompttitle.
+ lo_data_validation->prompt = ls_datavalidation-prompt.
+ lo_data_validation->errortitle = ls_datavalidation-errortitle.
+ lo_data_validation->error = ls_datavalidation-error.
+ lo_data_validation->errorstyle = ls_datavalidation-errorstyle.
+ lo_data_validation->cell_row = ls_datavalidation-cell_row.
+ lo_data_validation->cell_row_to = ls_datavalidation-cell_row_to.
+ lo_data_validation->cell_column = ls_datavalidation-cell_column.
+ lo_data_validation->cell_column_to = ls_datavalidation-cell_column_to.
+ endloop.
+ lo_ixml_datavalidation_elem ?= lo_ixml_iterator->get_next( ).
+ ENDWHILE.
+ " End fix 276 Read data validations
+
+ENDMETHOD.
@@ -2605,6 +2787,11 @@
path2 = path.
zcl_excel_common=>split_file( EXPORTING ip_file = path2
IMPORTING ep_extension = file_ext2 ).
+* CALL FUNCTION 'CV120_SPLIT_FILE'
+* EXPORTING
+* pf_file = path2
+* IMPORTING
+* pfx_extension = file_ext2.
rel_drawing-file_ext = file_ext2.
"-------------Added by Alessandro Iannacci - Should load graph xml
@@ -2654,110 +2841,7 @@
ENDDO.
- endmethod.
-
-
-
-
- METHOD read_from_applserver.
-
- DATA: lv_filelength TYPE i,
- lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY,
- ls_binary_data LIKE LINE OF lt_binary_data,
- lv_filename TYPE string,
- lv_max_length_line TYPE i,
- lv_actual_length_line TYPE i,
- lv_errormessage TYPE string.
-
- MOVE i_filename TO lv_filename.
-
- DESCRIBE FIELD ls_binary_data LENGTH lv_max_length_line IN BYTE MODE.
- OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
- IF sy-subrc <> 0.
- lv_errormessage = 'A problem occured when reading the file'(001).
- RAISE EXCEPTION TYPE zcx_excel
- EXPORTING
- error = lv_errormessage.
- ENDIF.
- WHILE sy-subrc = 0.
-
- READ DATASET lv_filename INTO ls_binary_data MAXIMUM LENGTH lv_max_length_line ACTUAL LENGTH lv_actual_length_line.
- APPEND ls_binary_data TO lt_binary_data.
- lv_filelength = lv_filelength + lv_actual_length_line.
-
- ENDWHILE.
- CLOSE DATASET lv_filename.
-
-*--------------------------------------------------------------------*
-* Binary data needs to be provided as XSTRING for further processing
-*--------------------------------------------------------------------*
- CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
- EXPORTING
- input_length = lv_filelength
- IMPORTING
- buffer = r_excel_data
- TABLES
- binary_tab = lt_binary_data.
- ENDMETHOD.
-
-
-
-
- METHOD read_from_local_file.
- DATA: lv_filelength TYPE i,
- lt_binary_data TYPE STANDARD TABLE OF x255 WITH NON-UNIQUE DEFAULT KEY,
- ls_binary_data LIKE LINE OF lt_binary_data,
- lv_filename TYPE string,
- lv_errormessage TYPE string.
-
- MOVE i_filename TO lv_filename.
-
- cl_gui_frontend_services=>gui_upload( EXPORTING
- filename = lv_filename
- filetype = 'BIN' " We are basically working with zipped directories --> force binary read
- IMPORTING
- filelength = lv_filelength
- CHANGING
- data_tab = lt_binary_data
- EXCEPTIONS
- file_open_error = 1
- file_read_error = 2
- no_batch = 3
- gui_refuse_filetransfer = 4
- invalid_type = 5
- no_authority = 6
- unknown_error = 7
- bad_data_format = 8
- header_not_allowed = 9
- separator_not_allowed = 10
- header_too_long = 11
- unknown_dp_error = 12
- access_denied = 13
- dp_out_of_memory = 14
- disk_full = 15
- dp_timeout = 16
- not_supported_by_gui = 17
- error_no_gui = 18
- OTHERS = 19 ).
- IF sy-subrc <> 0.
- lv_errormessage = 'A problem occured when reading the file'(001).
- RAISE EXCEPTION TYPE zcx_excel
- EXPORTING
- error = lv_errormessage.
- ENDIF.
-
-*--------------------------------------------------------------------*
-* Binary data needs to be provided as XSTRING for further processing
-*--------------------------------------------------------------------*
- CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
- EXPORTING
- input_length = lv_filelength
- IMPORTING
- buffer = r_excel_data
- TABLES
- binary_tab = lt_binary_data.
-
- ENDMETHOD.
+endmethod.
@@ -2765,10 +2849,10 @@
method RESOLVE_PATH.
*--------------------------------------------------------------------*
* ToDos:
-* 2do§1 Determine whether the replacement should be done
+* 2do§1 Determine whether the replacement should be done
* iterative to allow /../../.. or something alike
-* 2do§2 Determine whether /./ has to be supported as well
-* 2do§3 Create unit-test for this method
+* 2do§2 Determine whether /./ has to be supported as well
+* 2do§3 Create unit-test for this method
*
* Please don't just delete these ToDos if they are not
* needed but leave a comment that states this
@@ -2776,14 +2860,14 @@
*--------------------------------------------------------------------*
* issue #230 - Pimp my Code
-* - Stefan Schmöcker, (done) 2012-11-11
+* - Stefan Schmöcker, (done) 2012-11-11
* - ...
* changes: replaced previous coding by regular expression
* adding comments to explain what we are trying to achieve
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
-* §1 This routine will receive a path, that may have a relative pathname (/../) included somewhere
+* §1 This routine will receive a path, that may have a relative pathname (/../) included somewhere
* The output should be a resolved path without relative references
* Example: Input xl/worksheets/../drawings/drawing1.xml
* Output xl/drawings/drawing1.xml
@@ -2791,7 +2875,7 @@
rp_result = ip_path.
*--------------------------------------------------------------------*
-* §1 Remove relative pathnames
+* §1 Remove relative pathnames
*--------------------------------------------------------------------*
* Regular expression [^/]*/\.\./
* [^/]* --> any number of characters other than /
@@ -2801,10 +2885,10 @@
REPLACE REGEX '[^/]*/\.\./' IN rp_result WITH ``.
- endmethod.
+endmethod.
- method RESOLVE_REFERENCED_FORMULAE.
+ METHOD resolve_referenced_formulae.
TYPES: BEGIN OF ty_referenced_cells,
sheet TYPE REF TO zcl_excel_worksheet,
si TYPE i,
@@ -2900,6 +2984,6 @@
ENDLOOP.
ENDLOOP.
- endmethod.
+ENDMETHOD.