Bind Table: Overlapping tables should raise exception - FIXED

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@375 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
This commit is contained in:
Alessandro Iannacci 2012-12-01 18:08:28 +00:00
parent da997b79ee
commit 1b0a69d2b3
2 changed files with 70 additions and 4 deletions

View File

@ -2935,14 +2935,16 @@ endmethod.</source>
ls_settings-bottom_right_column = zcl_excel_common=&gt;convert_column2alpha( lv_maxcol ). ls_settings-bottom_right_column = zcl_excel_common=&gt;convert_column2alpha( lv_maxcol ).
ls_settings-bottom_right_row = lv_maxrow. ls_settings-bottom_right_row = lv_maxrow.
lv_column_int = zcl_excel_common=&gt;convert_column2int( ls_settings-top_left_column ).
&quot;Check if overlapping areas exist &quot;Check if overlapping areas exist
lo_iterator = me-&gt;tables-&gt;if_object_collection~get_iterator( ). lo_iterator = me-&gt;tables-&gt;if_object_collection~get_iterator( ).
WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true. WHILE lo_iterator-&gt;if_object_collection_iterator~has_next( ) EQ abap_true.
lo_curtable ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ). lo_curtable ?= lo_iterator-&gt;if_object_collection_iterator~get_next( ).
IF ls_settings-top_left_row GE lo_curtable-&gt;settings-top_left_row AND ls_settings-top_left_row LE lo_curtable-&gt;settings-bottom_right_row IF ( ls_settings-top_left_row GE lo_curtable-&gt;settings-top_left_row AND ls_settings-top_left_row LE lo_curtable-&gt;settings-bottom_right_row
OR ls_settings-bottom_right_row GE lo_curtable-&gt;settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable-&gt;settings-bottom_right_row. OR ls_settings-bottom_right_row GE lo_curtable-&gt;settings-top_left_row AND ls_settings-bottom_right_row LE lo_curtable-&gt;settings-bottom_right_row )
ELSEIF lv_column_int GE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-top_left_column ) AND lv_column_int LE lo_curtable-&gt;settings-bottom_right_column and ( lv_column_int GE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-top_left_column ) AND lv_column_int LE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-bottom_right_column )
OR lv_maxcol GE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-top_left_column ) AND lv_maxcol LE lo_curtable-&gt;settings-bottom_right_column. OR lv_maxcol GE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-top_left_column ) AND lv_maxcol LE zcl_excel_common=&gt;convert_column2int( lo_curtable-&gt;settings-bottom_right_column ) ).
RAISE EXCEPTION TYPE zcx_excel RAISE EXCEPTION TYPE zcx_excel
EXPORTING EXPORTING
error = &apos;It is not possible to bind two tables to an excelsheet with overlapping areas.&apos;. error = &apos;It is not possible to bind two tables to an excelsheet with overlapping areas.&apos;.

View File

@ -0,0 +1,64 @@
<?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: &lt;carr&gt; LIKE LINE OF lt_carr.
CONSTANTS: c_airlines TYPE string VALUE &apos;Airlines&apos;.
CONSTANTS: gc_save_file_name TYPE string VALUE &apos;03_iTab.xlsx&apos;.
INCLUDE zdemo_excel_outputopt_incl.
START-OF-SELECTION.
&quot; Creates active sheet
CREATE OBJECT lo_excel.
&quot; Get active sheet
lo_worksheet = lo_excel-&gt;get_active_worksheet( ).
lo_worksheet-&gt;set_title( ip_title = &apos;Internal table&apos;).
DATA lt_test TYPE TABLE OF sflight.
SELECT * FROM sflight INTO TABLE lt_test. &quot;#EC CI_NOWHERE
* First table - A:M
ls_table_settings-table_style = zcl_excel_table=&gt;builtinstyle_medium2.
ls_table_settings-show_row_stripes = abap_true.
ls_table_settings-top_left_column = &apos;A&apos;.
lo_worksheet-&gt;bind_table( ip_table = lt_test
is_table_settings = ls_table_settings ).
* Second (overlapping) table: K:T
ls_table_settings-top_left_column = &apos;K&apos;.
lo_worksheet-&gt;bind_table( ip_table = lt_test
is_table_settings = ls_table_settings ).
*** Create output
lcl_output=&gt;output( lo_excel ).</source>
</PROG>