09-27-2017 6:05 AM
I have concern regarding the use of cl_abap_char_utilities=>newline converted to XML.
the newline (ALT+Enter) in a cell is not displayed in the excel attachment. instead it is viewed as:
"text1, text2".
I was hoping the resulting output in a particular cell would be:
text1
text2
09-27-2017 12:47 PM
Based on your latest comments, you are using XMLSS, not OLE (and you are generating XMLSS via the ABAP iXML classes). In XML, all "space-like" characters (space, newline, tab...) are interpreted by default as one space. If you want to pass the actual values, you must use their equivalent "character entity references":
09-27-2017 7:14 AM
Did you set the cell's IsTextWrapped style to true
worksheet.Cell.Style.WrapText=true;
09-27-2017 11:45 AM
09-27-2017 11:46 AM
Hi Raymond Giuseppi,
I'm not sure where to insert that kind of code in abap. Are you referring to wraptext? could you provide some psuedocode? I tried something like this (below) in my code. but it is still not working.
r_format = l_document->create_simple_element( name = 'Alignment' parent = r_style ).
r_format->set_attribute_ns( name = 'Vertical' prefix = 'ss' value = 'Center' ).
r_format->set_attribute_ns( name = 'WrapText' prefix = 'ss' value = '1' ).
09-27-2017 11:54 AM
09-27-2017 12:09 PM
I was more thinking to something like (some test perform you should)
SET PROPERTY OF ole_cells/rows/columns 'WrapText' = 1.
09-28-2017 1:43 AM
Hi Raymond Giuseppi & Sandra Rossi. Apologies, I got confused between the two. But anyway, thanks for your big help.
09-28-2017 7:49 AM
09-28-2017 11:01 AM
Well when I tried to apply the character entity reference for newline. It is still not interpreted by the xml. I think I found another thread (https://archive.sap.com/discussions/thread/3380973) that has the similar problem. They just did some workaround regarding this. Another option I'm looking at is with the use abap2xlsx. But I'm still learning this approach. I'll try to provide another feedback about this, if it worked.
09-28-2017 11:19 AM
So without reference to OLE2, but building an Excel XML file, you could try to
Create a style like
in Workbook, Styles
<Style ss:ID="ZMultiLine">
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
</Style>
Use it in the Cell
<Cell ss:StyleID="ZMultiLine">
<Data ss:Type="String">First Line&XXX;Second Line&XXX;Last Line</Data>
</Cell>
Where XXX is for #10 (else your browser will replace it with line feed)
09-29-2017 1:36 AM
I'll get back to you as soon as I've tried and tested this. thank you Raymond Giuseppi.
10-02-2017 8:57 AM
HI Raymond Giuseppi, I have tried this. But I'm still not getting the expected output. The character entity reference for newline ( & #10;) is still not interpreted properly. But it's ok, I think I found the approach i'm looking for. Thank you.
09-27-2017 12:47 PM
Based on your latest comments, you are using XMLSS, not OLE (and you are generating XMLSS via the ABAP iXML classes). In XML, all "space-like" characters (space, newline, tab...) are interpreted by default as one space. If you want to pass the actual values, you must use their equivalent "character entity references":
09-29-2017 11:35 AM
To do "Line 1& #10;Line 2":
data = lo_doc->create_simple_element( name = 'Data' parent = cell ).
text = lo_doc->create_text( ).
text->set_value( value = 'Line 1' ).
data->append_child( text ).
ref = lo_doc->create_entity_ref( name = '#10' ).
data->append_child( ref ).
text = lo_doc->create_text( ).
text->set_value( value = 'Line 2' ).
data->append_child( text ).
10-02-2017 8:05 AM
05-13-2021 3:24 AM
If it is multiple lines like Ex 10 lines how the functionality will work code please
05-13-2021 3:25 AM
Thanks for coming to SAP Community for answers. Please post your question as a new question here:
https://answers.sap.com/questions/ask.htmlSince you're new in asking questions here, check out our tutorial about asking and answering questions (if you haven't already), as it provides tips for preparing questions more effectively, that draw responses from our members. Please note, that your post here won't be answered.