Fixed issue #348: Referenced formulae truncated

CLASS ZCL_EXCEL_COMMON : Extended length of internal field - now we'd really need huuuuuuuge formulae before we truncate ( was afraid to switch to string, no time to analyze if that is feasible )
CLASS ZCL_EXCEL_STYLE_COLOR: Added a method to allow creating rgb-colors with integer input instead of hex-input for the colors
Report ZDEMO_EXCEL37:  Added line to create output when using alternate writerclass ( was buggy after my extension of the report ), added code to save .xlsm templates as .xlsm when downloading, added set-get-parameter for better handling
This commit is contained in:
StefanSchmoecker 2015-01-05 13:46:41 +01:00
parent 7fdba5e3a4
commit 600ac8a159
3 changed files with 48 additions and 7 deletions

View File

@ -2213,7 +2213,7 @@ endmethod.</source>
lv_numchars TYPE i, &quot; Number of characters counter
lv_tchar(1) TYPE c, &quot; Temp character
lv_tchar2(1) TYPE c, &quot; Temp character
lv_cur_form(132) TYPE c, &quot; Formula for current cell
lv_cur_form(2000) TYPE c, &quot; Formula for current cell
lv_ref_cell_addr TYPE string, &quot; Reference cell address
lv_tcol1 TYPE string, &quot; Temp column letter
lv_tcol2 TYPE string, &quot; Temp column letter

View File

@ -35,16 +35,48 @@
<attribute CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="C_THEME_NOT_SET" VERSION="1" LANGU="E" DESCRIPT="Theme Color - Not Set" EXPOSURE="2" STATE="1" EDITORDER="24 " ATTDECLTYP="2" ATTVALUE="-1" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_THEME" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="C_WHITE" VERSION="1" LANGU="E" DESCRIPT="Color ARGB" EXPOSURE="2" STATE="1" EDITORDER="10 " ATTDECLTYP="2" ATTVALUE="&apos;FFFFFFFF&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<attribute CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="C_YELLOW" VERSION="1" LANGU="E" DESCRIPT="Color ARGB" EXPOSURE="2" STATE="1" EDITORDER="11 " ATTDECLTYP="2" ATTVALUE="&apos;FFFFFF00&apos;" ATTEXPVIRT="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB" SRCROW1="0 " SRCCOLUMN1="0 " SRCROW2="0 " SRCCOLUMN2="0 " TYPESRC_LENG="0 "/>
<method CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARBG_INT" VERSION="1" LANGU="E" DESCRIPT="Create a custom ARGB color from RGB with integers" EXPOSURE="2" STATE="1" EDITORDER="2 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="1" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARBG_INT" SCONAME="IV_RED" VERSION="1" LANGU="E" DESCRIPT="Dummy for B20 int1 (Local Everywhere)" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="NUMERIC"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARBG_INT" SCONAME="IV_GREEN" VERSION="1" LANGU="E" DESCRIPT="Dummy for B20 int1 (Local Everywhere)" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="NUMERIC"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARBG_INT" SCONAME="IV_BLUE" VERSION="1" LANGU="E" DESCRIPT="Dummy for B20 int1 (Local Everywhere)" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="NUMERIC"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARBG_INT" SCONAME="RV_COLOR_ARGB" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB"/>
<source>METHOD create_new_arbg_int.
DATA: lv_red TYPE int1,
lv_green TYPE int1,
lv_blue TYPE int1,
lv_hex TYPE x,
lv_char_red TYPE zexcel_style_color_component,
lv_char_green TYPE zexcel_style_color_component,
lv_char_blue TYPE zexcel_style_color_component.
lv_red = iv_red MOD 256.
lv_green = iv_green MOD 256.
lv_blue = iv_blue MOD 256.
lv_hex = lv_red.
lv_char_red = lv_hex.
lv_hex = lv_green.
lv_char_green = lv_hex.
lv_hex = lv_blue.
lv_char_blue = lv_hex.
concatenate zcl_excel_style_color=&gt;c_alpha lv_char_red lv_char_green lv_char_blue into rv_color_argb.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARGB" VERSION="1" LANGU="E" DESCRIPT="Create a custom ARGB color from RGB" EXPOSURE="2" STATE="1" EDITORDER="1 " DISPID="0 " MTDTYPE="0" MTDDECLTYP="1" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARGB" SCONAME="IP_RED" VERSION="1" LANGU="E" DESCRIPT="Color Component" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_COMPONENT"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARGB" SCONAME="IP_GREEN" VERSION="1" LANGU="E" DESCRIPT="Color Component" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_COMPONENT"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARGB" SCONAME="IP_BLU" VERSION="1" LANGU="E" DESCRIPT="Color Component" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_COMPONENT"/>
<parameter CLSNAME="ZCL_EXCEL_STYLE_COLOR" CMPNAME="CREATE_NEW_ARGB" SCONAME="EP_COLOR_ARGB" VERSION="1" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " PARDECLTYP="3" PARPASSTYP="0" TYPTYPE="1" TYPE="ZEXCEL_STYLE_COLOR_ARGB"/>
<source>method CREATE_NEW_ARGB.
<source>METHOD create_new_argb.
CONCATENATE zcl_excel_style_color=&gt;c_alpha ip_red ip_green ip_blu INTO ep_color_argb.
endmethod.</source>
ENDMETHOD.</source>
</method>
</CLAS>

View File

@ -29,17 +29,17 @@
DATA: excel TYPE REF TO zcl_excel,
reader TYPE REF TO zif_excel_reader,
go_error TYPE REF TO cx_root,
gv_memid_gr8 TYPE text255,
gv_message TYPE string,
lv_extension TYPE string,
gv_error_program_name TYPE syrepid,
gv_error_include_name TYPE syrepid,
gv_error_line TYPE i.
CONSTANTS: gc_save_file_name TYPE string VALUE &apos;37- Read template and output.xlsx&apos;.
DATA: gc_save_file_name TYPE string VALUE &apos;37- Read template and output.&amp;&apos;.
SELECTION-SCREEN BEGIN OF BLOCK blx WITH FRAME.
PARAMETERS: p_upfile TYPE string DEFAULT &apos;c:\temp\whatever.xlsx&apos; LOWER CASE.
PARAMETERS: p_upfile TYPE string LOWER CASE MEMORY ID gr8.
SELECTION-SCREEN END OF BLOCK blx.
INCLUDE zdemo_excel_outputopt_incl.
@ -60,6 +60,12 @@ SELECTION-SCREEN END OF BLOCK bl_err.
INITIALIZATION.
PERFORM setup_listboxes.
cmt_dump = text-dum.
GET PARAMETER ID &apos;GR8&apos; FIELD gv_memid_gr8.
p_upfile = gv_memid_gr8.
IF p_upfile IS INITIAL.
p_upfile = &apos;c:\temp\whatever.xlsx&apos;.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upfile.
PERFORM f4_p_upfile CHANGING p_upfile.
@ -275,6 +281,7 @@ FORM read_template RAISING zcx_excel .
WHEN OTHERS.
CREATE OBJECT reader TYPE (lb_read).
excel = reader-&gt;load_file( p_upfile ).
&quot;Use template for charts
excel-&gt;use_template = abap_true.
@ -296,9 +303,11 @@ FORM write_template RAISING zcx_excel.
CASE lv_extension.
WHEN &apos;.XLSX&apos;.
REPLACE &apos;&amp;&apos; IN gc_save_file_name WITH &apos;xlsx&apos;. &quot; Pass extension for standard writer
lcl_output=&gt;output( excel ).
WHEN &apos;.XLSM&apos;.
REPLACE &apos;&amp;&apos; IN gc_save_file_name WITH &apos;xlsm&apos;. &quot; Pass extension for macro-writer
lcl_output=&gt;output( cl_excel = excel
iv_writerclass_name = &apos;ZCL_EXCEL_WRITER_XLSM&apos; ).