Skip to Content
2
Jul 17, 2020 at 06:16 PM

Need to display TIme Format in excel via XML code in SAP ABAP

476 Views

I am generating excel file through XML code via background Job and the same excel is being sent through email.

I want to display time field like 09:34AM . Through program I am passing time value as 09:30:23 but when it will display in excel it should follow the time format like hh:mm AM. But when I am opening the excel it is displaying like 09:34:23 but when I am double clicking on the cell then it is taking the desired format like 09:34AM. Can you please help me to fix this issue.

Code snippet:

** 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 = 'Data2' ). r_format = l_document->create_simple_element( name = 'NumberFormat' parent = r_style3 ).
r_format->set_attribute_ns( name = 'Format' prefix = 'ss' value = 'h:mm AM/PM' ). r_format = l_document->create_simple_element( name = 'Alignment' parent = r_style3 ).
r_format->set_attribute_ns( name = 'Vertical' prefix = 'ss' value = 'Top' ).
r_format->set_attribute_ns( name = 'WrapText' prefix = 'ss' value = '1' ).

lv_time = '122523'.
WRITE lv_time TO lv_data USING EDIT MASK '__:__:__'.
MOVE lv_data TO l_value.
r_cell = l_document->create_simple_element( name = 'Cell' parent = r_row ).
r_cell->set_attribute_ns( name = 'StyleID' prefix = 'ss' value = 'Data2' ).
r_data = l_document->create_simple_element( name = 'Data' value = l_value parent = r_cell ).
r_data->set_attribute_ns( name = 'Type' prefix = 'ss' value = 'String' ).