‎2019 Mar 05 1:45 PM
Hello Experts ,
I created a program to send formated XLS attachment . For formated XLS attachement I used XML code .
This is working fine ..If the same code I use in existing program while opening the attachment I am getting the
style error . I tried all permutations and combinations but still I am getting the style error .
Will any body please guide me on this ..
Thanks,
Santosh.v
‎2019 Mar 05 1:59 PM
Please clarify these two parts are not clear:
‎2019 Mar 05 2:25 PM
Try to remove any formatting (unless you need it) or minimally, change the fonts that are being used to ones that are available in Excel.
‎2019 Mar 05 2:26 PM
I created the separate program to send formated xls attachment I used XML code . If I open the attachment in SOST it is opening properly ..
I have the same in requirement in existing(Old program) program ..I am using the same code which is in created program ..
In SOST I can see the attachment If I try to open the attachment I am getting he STYLE error ..
Please check the screen shot for your reference in the attachment .capture.png
‎2019 Mar 05 3:14 PM
You wrote 'For formatted XLS attachment I used XML code.' But that's not possible, XML can only generate XLSX format, not XLS (Microsoft proprietary format)
Could you elaborate on your question, and provide more information on the generated XML, how was it created, did you use some transformation, some CL_XLSX_DOCUMENT class or even ABAP2XLSX tools ?
‎2019 Mar 06 2:18 AM
you should check the log to know what error you got (there is log file location in the pop-up) and try to remove the error xml code. This maybe because of the xml you generated doesnt supported by the version of office you using. Anw, you should tell us what method, what class or some code that you using to generate xml file or all you get just a guess.
‎2019 Mar 06 7:33 AM
Hi ,
I tried to find he location also I am able to find up to windows after that I cant able to find the remaining folders . I searched for hidden folders also ..
Please find the code which is used by me ..
l_ixml = cl_ixml=>create( ).
*
** Creating the DOM Object Model
* l_document = l_ixml->create_document( ).
*
** Create Root Node 'Workbook'
* l_element_root = l_document->create_simple_element( name = 'Workbook' parent = l_document ).
* l_element_root->set_attribute( name = 'xmlns' value = 'urn:schemas-microsoft-com:office:spreadsheet' ).
*
* ns_attribute = l_document->create_namespace_decl( name = 'ss' prefix = 'xmlns' uri = 'urn:schemas-microsoft-com:office:spreadsheet' ).
* l_element_root->set_attribute_node( ns_attribute ).
*
* ns_attribute = l_document->create_namespace_decl( name = 'x' prefix = 'xmlns' uri = 'urn:schemas-microsoft-com:office:excel' ).
* l_element_root->set_attribute_node( ns_attribute ).
*
** Create node for document properties.
* r_element_properties = l_document->create_simple_element( name = 'TEST_REPORT' parent = l_element_root ).
* l_value = sy-uname.
* l_document->create_simple_element( name = 'Author' value = l_value parent = r_element_properties ).
*
** Styles
* r_styles = l_document->create_simple_element( name = 'Styles' parent = l_element_root ).
*
** Style for Header
* r_style = l_document->create_simple_element( name = 'Style' parent = r_styles ).
* r_style->set_attribute_ns( name = 'ID' prefix = 'ss' value = 'Header' ).
*
* r_format = l_document->create_simple_element( name = 'Font' parent = r_style ).
* r_format->set_attribute_ns( name = 'Bold' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Interior' parent = r_style ).
* r_format->set_attribute_ns( name = 'Color' prefix = 'ss' value = '#92D050' ).
* r_format->set_attribute_ns( name = 'Pattern' prefix = 'ss' value = 'Solid' ).
*
* 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' ).
*
* r_border = l_document->create_simple_element( name = 'Borders' parent = r_style ).
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Bottom' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Left' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Top' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Right' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
** Style for Data
* r_style3 = l_document->create_simple_element( name = 'Style' parent = r_styles ).
* r_style3->set_attribute_ns( name = 'ID' prefix = 'ss' value = 'Data' ).
*
* r_border = l_document->create_simple_element( name = 'Borders' parent = r_style3 ).
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Bottom' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Left' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Top' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
* r_format = l_document->create_simple_element( name = 'Border' parent = r_border ).
* r_format->set_attribute_ns( name = 'Position' prefix = 'ss' value = 'Right' ).
* r_format->set_attribute_ns( name = 'LineStyle' prefix = 'ss' value = 'Continuous' ).
* r_format->set_attribute_ns( name = 'Weight' prefix = 'ss' value = '1' ).
*
*
** Worksheet
* r_worksheet = l_document->create_simple_element( name = 'Worksheet' parent = l_element_root ).
* r_worksheet->set_attribute_ns( name = 'Name' prefix = 'ss' value = 'Sheet1' ).
*
** Table
* r_table = l_document->create_simple_element( name = 'Table' parent = r_worksheet ).
* r_table->set_attribute_ns( name = 'FullColumns' prefix = 'x' value = '1' ).
* r_table->set_attribute_ns( name = 'FullRows' prefix = 'x' value = '1' ).
*
** Column Formatting
* r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
* r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '30' ).
*
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '20' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '20' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '30' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '20' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '30' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '55' ).
**
** r_column = l_document->create_simple_element( name = 'Column' parent = r_table ).
** r_column->set_attribute_ns( name = 'Width' prefix = 'ss' value = '65' ).
*
** Blank Row
* r_row = l_document->create_simple_element( name = 'Row' parent = r_table ).
*
** Column Headers Row
* r_row = l_document->create_simple_element( name = 'Row' parent = r_table ).
* r_row->set_attribute_ns( name = 'AutoFitHeight' prefix = 'ss' value = '1' ).
*
** Sr. No.
* r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
* r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
* r_data = l_document->create_simple_element( name = 'Data' value = 'Sr. No.' parent = r_cell ).
* r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
*
*** Material No.
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'GL' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Material Description
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Year' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Plant
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Plant' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Storage Location
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Storage Location' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Batch
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Batch' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Expired Date
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Expired Date' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).
**
*** Unrestricted Quantity
** r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
** r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Header' ).
** r_data = l_document->create_simple_element( name = 'Data' value = 'Unrestricted Quantity' parent = r_cell ).
** r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).Thanks,
Santhosh.v
‎2019 Mar 06 8:48 AM
Please use the COMMENT button. ANSWER is only to propose a solution.
Please use the CODE button to format your code nicely.
‎2019 Mar 06 11:06 AM
Sorry i dont have time to check your code but I just want to ask: is it not easier to using transformation in this case? you know, just have to save excel template to xml format and copy to transformation.
‎2019 Mar 06 8:52 AM
So you use the old XMLSS format (excel 2003). Don't you want to use Excel 2007 format (XLSX) by using the cool ABAP2XLSX tool ? (and you wouln't have this kind of error)
‎2019 Mar 06 8:57 AM
Methodology to solve yourself: create the Excel document via Excel, save it as Excel 2003 (XML), open it with an XML editor, write your ABAP code to generate the same XML, compare what is different and adjust your ABAP code, repeat until it's the same.