2023 Feb 13 11:20 AM
Dear ABAP2XLS users,
I use ABAP2XLS to create an Excel-File from ALV list.
There are two steps pending:
1. Assign the WRAPTEXT style to all cells.
2. Calculate optimal width for all comluns.
As I do not know how Excel-Files work internally I can not figure out a good aproach. All examples I saw are related to only one cell (assign style) or one column.
Are there any ideas or exmples which are helpfull?
Thanks in advance
Thomas
2023 Feb 13 5:55 PM
For wrapping the text, there is the demo program ZDEMO_EXCEL14 (abap2xlsx Demo: Alignment).
abap2xlsx may calculate approximately the width of a column based on the texts contained in it. For this to work, you must install the True Type fonts in SE73. There is the demo program ZDEMO_EXCEL31 (abap2xlsx Demo: Autosize Column with different Font sizes). If the fonts are not installed in SE73, the logic will be based on the number of characters, considering all have the same width, and on the font size.
I don't see what issue you have to apply to all cells and all columns.
You can pull all the demo programs in your system, from the repository Demos.
For ALV, you also have CL_SALV_TABLE=>TO_XML which creates an XLSX file.
EDIT: to apply a style on all cells, you can either set a default style (SET_DEFAULT_STYLE in ZCL_EXCEL), or use the method CHANGE_AREA_STYLE to change parts of styles of a range of cells (ZDEMO_EXCEL40).
lo_style_changer = zcl_excel_style_changer=>create( lo_excel ).
lo_style_changer->set_alignment_wraptext( zcl_excel_style_alignment=>wraptext ).
lo_worksheet->change_area_style(
ip_range = 'A1:T3'
ip_style_changer = lo_style_changer ).
2023 Feb 17 11:26 AM
Hi Sandra,
Thanks for your addition. It is really helpfull.
Kind Regards
thomas
2023 Feb 16 8:02 AM
Hi Sandra,
Thanks for your reply.
I already know the program ZDEMO_EXCEL14. As I already mentioned in the whole program the method LO_WORKSHEET->SET_CELL is used to apply a style to a single cell. Of course I can iterate over all cells and use the SET_CELL_STYLE method to apply a WRAPTEXT style. But I hope that there is a better method to apply the style to all cells of a worksheet.
Kind Regards,
Thomas
2023 Feb 16 8:35 AM
Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
2023 Feb 16 8:42 AM