mirror of
https://github.com/abap2xlsx/abap2xlsx.git
synced 2025-05-05 07:56:15 +08:00
leave at test #227 because of minor cosmetic changes
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@376 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
parent
1b0a69d2b3
commit
14699b93ab
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CLAS CLSNAME="ZCL_EXCEL_WORKSHEET" VERSION="1" LANGU="E" DESCRIPT="Worksheet" UUID="C1BF274C8A345F2DE1000000C0A8FA19" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 ">
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_PROPERTIES" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1" EDITORDER="0 "/>
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_PROTECTION" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1" EDITORDER="0 "/>
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_VBA_PROJECT" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1" EDITORDER="0 "/>
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_PROPERTIES" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1"/>
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_PROTECTION" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1"/>
|
||||
<implementing CLSNAME="ZCL_EXCEL_WORKSHEET" REFCLSNAME="ZIF_EXCEL_SHEET_VBA_PROJECT" VERSION="1" EXPOSURE="2" STATE="1" RELTYPE="1"/>
|
||||
<publicSection>class ZCL_EXCEL_WORKSHEET definition
|
||||
public
|
||||
final
|
||||
|
@ -596,8 +596,13 @@ endclass.</localTypes>
|
|||
<localMacros>*"* use this source file for any macro definitions you need
|
||||
*"* in the implementation part of the class</localMacros>
|
||||
<textPool>
|
||||
<language SPRAS="D">
|
||||
<textElement ID="I" KEY="001" ENTRY="Tabelle" LENGTH="132 "/>
|
||||
<textElement ID="I" KEY="400" ENTRY="Tabelle überschneidet sich mit schon eingebundener Tabelle und wird diesem Tabellenblatt nicht hinzugefügt." LENGTH="132 "/>
|
||||
</language>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="I" KEY="001" ENTRY="Sheet" LENGTH="132 "/>
|
||||
<textElement ID="I" KEY="400" ENTRY="Table overlaps with previously bound table and will not be added to worksheet." LENGTH="132 "/>
|
||||
</language>
|
||||
</textPool>
|
||||
<typeUsage CLSNAME="ZCL_EXCEL_WORKSHEET" TYPEGROUP="ABAP" VERSION="1" TPUTYPE="0" EXPLICIT="X"/>
|
||||
|
@ -2862,38 +2867,51 @@ endmethod.</source>
|
|||
<parameter CLSNAME="ZCL_EXCEL_WORKSHEET" CMPNAME="BIND_TABLE" SCONAME="ES_TABLE_SETTINGS" VERSION="1" LANGU="E" DESCRIPT="Excel table binding settings" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_S_TABLE_SETTINGS"/>
|
||||
<exception CLSNAME="ZCL_EXCEL_WORKSHEET" CMPNAME="BIND_TABLE" SCONAME="ZCX_EXCEL" VERSION="1" LANGU="E" DESCRIPT="Exceptions for ABAP2XLSX" MTDTYPE="0" EDITORDER="1 "/>
|
||||
<source>METHOD bind_table.
|
||||
|
||||
DATA:
|
||||
lv_row_int TYPE zexcel_cell_row,
|
||||
lv_first_row TYPE zexcel_cell_row,
|
||||
lv_last_row TYPE zexcel_cell_row,
|
||||
lv_column_int TYPE zexcel_cell_column,
|
||||
lv_column_alpha TYPE zexcel_cell_column_alpha,
|
||||
lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
lv_id TYPE i,
|
||||
lv_rows TYPE i,
|
||||
lv_formula TYPE string,
|
||||
ls_settings TYPE zexcel_s_table_settings,
|
||||
lo_table TYPE REF TO zcl_excel_table,
|
||||
lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line,
|
||||
lv_value TYPE string,
|
||||
lv_syindex TYPE char3.
|
||||
|
||||
DATA lv_columns TYPE i.
|
||||
DATA lt_columns TYPE zexcel_t_fieldcatalog.
|
||||
DATA lv_maxcol TYPE i.
|
||||
DATA lv_maxrow TYPE i.
|
||||
DATA lo_iterator TYPE REF TO cl_object_collection_iterator.
|
||||
DATA lo_curtable TYPE REF TO zcl_excel_table.
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #230 - Pimp my Code
|
||||
* - Stefan Schmöcker, (wi p) 2012-12-01
|
||||
* - ...
|
||||
* aligning code
|
||||
* message made to support multilinguality
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #237 - Check if overlapping areas exist
|
||||
* - Alessandro Iannacci 2012-12-01
|
||||
* changes: - Added raise if overlaps are detected
|
||||
*--------------------------------------------------------------------*
|
||||
|
||||
CONSTANTS:
|
||||
lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B',
|
||||
lc_top_left_row TYPE zexcel_cell_row VALUE '3'.
|
||||
lc_top_left_column TYPE zexcel_cell_column_alpha VALUE 'B',
|
||||
lc_top_left_row TYPE zexcel_cell_row VALUE '3'.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field_catalog> TYPE zexcel_s_fieldcatalog,
|
||||
<ls_field_catalog_custom> TYPE zexcel_s_fieldcatalog,
|
||||
<fs_table_line> TYPE any,
|
||||
<fs_fldval> TYPE any.
|
||||
DATA:
|
||||
lv_row_int TYPE zexcel_cell_row,
|
||||
lv_first_row TYPE zexcel_cell_row,
|
||||
lv_last_row TYPE zexcel_cell_row,
|
||||
lv_column_int TYPE zexcel_cell_column,
|
||||
lv_column_alpha TYPE zexcel_cell_column_alpha,
|
||||
lt_field_catalog TYPE zexcel_t_fieldcatalog,
|
||||
lv_id TYPE i,
|
||||
lv_rows TYPE i,
|
||||
lv_formula TYPE string,
|
||||
ls_settings TYPE zexcel_s_table_settings,
|
||||
lo_table TYPE REF TO zcl_excel_table,
|
||||
lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line,
|
||||
lv_value TYPE string,
|
||||
lv_syindex TYPE char3,
|
||||
lv_errormessage TYPE string, "ins issue #237
|
||||
|
||||
lv_columns TYPE i,
|
||||
lt_columns TYPE zexcel_t_fieldcatalog,
|
||||
lv_maxcol TYPE i,
|
||||
lv_maxrow TYPE i,
|
||||
lo_iterator TYPE REF TO cl_object_collection_iterator,
|
||||
lo_curtable TYPE REF TO zcl_excel_table.
|
||||
|
||||
FIELD-SYMBOLS:
|
||||
<ls_field_catalog> TYPE zexcel_s_fieldcatalog,
|
||||
<ls_field_catalog_custom> TYPE zexcel_s_fieldcatalog,
|
||||
<fs_table_line> TYPE ANY,
|
||||
<fs_fldval> TYPE ANY.
|
||||
|
||||
ls_settings = is_table_settings.
|
||||
|
||||
|
@ -2917,6 +2935,9 @@ endmethod.</source>
|
|||
|
||||
SORT lt_field_catalog BY position.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #237 Check if overlapping areas exist Start
|
||||
*--------------------------------------------------------------------*
|
||||
"Get the number of columns for the current table
|
||||
lt_columns = lt_field_catalog.
|
||||
DELETE lt_columns WHERE dynpfld NE abap_true.
|
||||
|
@ -2930,26 +2951,36 @@ endmethod.</source>
|
|||
DESCRIBE TABLE ip_table LINES lv_rows.
|
||||
|
||||
"Calculate the bottom right row for the current table
|
||||
lv_maxcol = lv_column_int + lv_columns - 1.
|
||||
lv_maxrow = lv_row_int + lv_rows - 1.
|
||||
lv_maxcol = lv_column_int + lv_columns - 1.
|
||||
lv_maxrow = lv_row_int + lv_rows - 1.
|
||||
ls_settings-bottom_right_column = zcl_excel_common=>convert_column2alpha( lv_maxcol ).
|
||||
ls_settings-bottom_right_row = lv_maxrow.
|
||||
|
||||
lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ).
|
||||
lv_column_int = zcl_excel_common=>convert_column2int( ls_settings-top_left_column ).
|
||||
|
||||
"Check if overlapping areas exist
|
||||
lo_iterator = me->tables->if_object_collection~get_iterator( ).
|
||||
WHILE lo_iterator->if_object_collection_iterator~has_next( ) EQ abap_true.
|
||||
|
||||
lo_curtable ?= lo_iterator->if_object_collection_iterator~get_next( ).
|
||||
IF ( ls_settings-top_left_row GE lo_curtable->settings-top_left_row AND ls_settings-top_left_row LE lo_curtable->settings-bottom_right_row
|
||||
OR ls_settings-bottom_right_row GE lo_curtable->settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable->settings-bottom_right_row )
|
||||
and ( lv_column_int GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_column_int LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column )
|
||||
OR lv_maxcol GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_maxcol LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column ) ).
|
||||
IF ( ( ls_settings-top_left_row GE lo_curtable->settings-top_left_row AND ls_settings-top_left_row LE lo_curtable->settings-bottom_right_row )
|
||||
OR
|
||||
( ls_settings-bottom_right_row GE lo_curtable->settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable->settings-bottom_right_row )
|
||||
)
|
||||
AND
|
||||
( ( lv_column_int GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_column_int LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column ) )
|
||||
OR
|
||||
( lv_maxcol GE zcl_excel_common=>convert_column2int( lo_curtable->settings-top_left_column ) AND lv_maxcol LE zcl_excel_common=>convert_column2int( lo_curtable->settings-bottom_right_column ) )
|
||||
).
|
||||
lv_errormessage = 'Table overlaps with previously bound table and will not be added to worksheet.'(400).
|
||||
RAISE EXCEPTION TYPE zcx_excel
|
||||
EXPORTING
|
||||
error = 'It is not possible to bind two tables to an excelsheet with overlapping areas.'.
|
||||
error = lv_errormessage.
|
||||
ENDIF.
|
||||
|
||||
ENDWHILE.
|
||||
*--------------------------------------------------------------------*
|
||||
* issue #237 Check if overlapping areas exist End
|
||||
*--------------------------------------------------------------------*
|
||||
|
||||
CREATE OBJECT lo_table.
|
||||
lo_table->settings = ls_settings.
|
||||
|
@ -2982,6 +3013,7 @@ endmethod.</source>
|
|||
<ls_field_catalog>-scrtext_l = lv_value.
|
||||
ENDIF.
|
||||
WHILE 1 = 1.
|
||||
|
||||
READ TABLE lt_column_name_buffer TRANSPORTING NO FIELDS WITH KEY table_line = lv_value BINARY SEARCH.
|
||||
IF sy-subrc <> 0.
|
||||
<ls_field_catalog>-scrtext_l = lv_value.
|
||||
|
@ -2991,6 +3023,7 @@ endmethod.</source>
|
|||
lv_syindex = sy-index.
|
||||
CONCATENATE <ls_field_catalog>-scrtext_l lv_syindex INTO lv_value.
|
||||
ENDIF.
|
||||
|
||||
ENDWHILE.
|
||||
" First of all write column header
|
||||
IF <ls_field_catalog>-style_header IS NOT INITIAL.
|
||||
|
@ -3006,6 +3039,7 @@ endmethod.</source>
|
|||
|
||||
ADD 1 TO lv_row_int.
|
||||
LOOP AT ip_table ASSIGNING <fs_table_line>.
|
||||
|
||||
ASSIGN COMPONENT <ls_field_catalog>-fieldname OF STRUCTURE <fs_table_line> TO <fs_fldval>.
|
||||
IF <ls_field_catalog>-style IS NOT INITIAL.
|
||||
me->set_cell( ip_column = lv_column_alpha
|
||||
|
@ -3018,6 +3052,7 @@ endmethod.</source>
|
|||
ip_value = <fs_fldval> ).
|
||||
ENDIF.
|
||||
ADD 1 TO lv_row_int.
|
||||
|
||||
ENDLOOP.
|
||||
IF sy-subrc <> 0. "create empty row if table has no data
|
||||
me->set_cell( ip_column = lv_column_alpha
|
||||
|
@ -3026,7 +3061,9 @@ endmethod.</source>
|
|||
ADD 1 TO lv_row_int.
|
||||
ENDIF.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
" totals
|
||||
*--------------------------------------------------------------------*
|
||||
IF <ls_field_catalog>-totals_function IS NOT INITIAL.
|
||||
lv_formula = lo_table->get_totals_formula( ip_column = <ls_field_catalog>-scrtext_l ip_function = <ls_field_catalog>-totals_function ).
|
||||
IF <ls_field_catalog>-style_total IS NOT INITIAL.
|
||||
|
@ -3044,7 +3081,9 @@ endmethod.</source>
|
|||
lv_row_int = ls_settings-top_left_row.
|
||||
ADD 1 TO lv_column_int.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
" conditional formatting
|
||||
*--------------------------------------------------------------------*
|
||||
IF <ls_field_catalog>-cond_style IS NOT INITIAL.
|
||||
lv_first_row = ls_settings-top_left_row + 1. " +1 to exclude header
|
||||
lv_last_row = ls_settings-top_left_row + lv_rows.
|
||||
|
@ -3053,9 +3092,12 @@ endmethod.</source>
|
|||
ip_stop_column = lv_column_alpha
|
||||
ip_stop_row = lv_last_row ).
|
||||
ENDIF.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
*--------------------------------------------------------------------*
|
||||
" Set field catalog
|
||||
*--------------------------------------------------------------------*
|
||||
lo_table->fieldcat = lt_field_catalog[].
|
||||
|
||||
es_table_settings = ls_settings.
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PROG NAME="ZERROR_A2X_BIND_TABLE_OVERLAP" VARCL="X" SUBC="1" RSTAT="T" RMAND="001" RLOAD="E" FIXPT="X" UCCHECK="X">
|
||||
<textPool>
|
||||
<language SPRAS="E">
|
||||
<textElement ID="R" ENTRY="abap2xlsx Demo: Export internal table" LENGTH="38 "/>
|
||||
<textElement ID="S" KEY="P_EMPTY" ENTRY=" Leave Table Empty" LENGTH="25 "/>
|
||||
<textElement ID="S" KEY="P_PATH" ENTRY="D ." LENGTH="24 "/>
|
||||
</language>
|
||||
</textPool>
|
||||
<source>REPORT zerror_a2x_bind_table_overlap.
|
||||
|
||||
TYPE-POOLS: abap.
|
||||
|
||||
DATA: lo_excel TYPE REF TO zcl_excel,
|
||||
lo_worksheet TYPE REF TO zcl_excel_worksheet,
|
||||
column_dimension TYPE REF TO zcl_excel_worksheet_columndime.
|
||||
|
||||
DATA: ls_table_settings TYPE zexcel_s_table_settings.
|
||||
|
||||
|
||||
DATA: lv_title TYPE zexcel_sheet_title,
|
||||
lt_carr TYPE TABLE OF scarr,
|
||||
row TYPE zexcel_cell_row VALUE 2,
|
||||
lo_range TYPE REF TO zcl_excel_range.
|
||||
DATA: lo_data_validation TYPE REF TO zcl_excel_data_validation.
|
||||
FIELD-SYMBOLS: <carr> LIKE LINE OF lt_carr.
|
||||
|
||||
CONSTANTS: c_airlines TYPE string VALUE 'Airlines'.
|
||||
|
||||
|
||||
CONSTANTS: gc_save_file_name TYPE string VALUE '03_iTab.xlsx'.
|
||||
INCLUDE zdemo_excel_outputopt_incl.
|
||||
|
||||
START-OF-SELECTION.
|
||||
" Creates active sheet
|
||||
CREATE OBJECT lo_excel.
|
||||
|
||||
" Get active sheet
|
||||
lo_worksheet = lo_excel->get_active_worksheet( ).
|
||||
lo_worksheet->set_title( ip_title = 'Internal table').
|
||||
|
||||
DATA lt_test TYPE TABLE OF sflight.
|
||||
|
||||
SELECT * FROM sflight INTO TABLE lt_test. "#EC CI_NOWHERE
|
||||
|
||||
* First table - A:M
|
||||
|
||||
ls_table_settings-table_style = zcl_excel_table=>builtinstyle_medium2.
|
||||
ls_table_settings-show_row_stripes = abap_true.
|
||||
ls_table_settings-top_left_column = 'A'.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_test
|
||||
is_table_settings = ls_table_settings ).
|
||||
|
||||
* Second (overlapping) table: K:T
|
||||
|
||||
ls_table_settings-top_left_column = 'K'.
|
||||
|
||||
lo_worksheet->bind_table( ip_table = lt_test
|
||||
is_table_settings = ls_table_settings ).
|
||||
|
||||
*** Create output
|
||||
lcl_output=>output( lo_excel ).</source>
|
||||
</PROG>
|
Loading…
Reference in New Issue
Block a user