cancel
Showing results for 
Search instead for 
Did you mean: 

Export to Excel - leading zeros problem

alberto_colonna
Participant
0 Kudos

Hello,

I wrote an application, which exports the data from an internal table into an excel file.

I defined a variable as char20. The variable contains the value '000256'.

When I generate the excel file, the leading zeros are cut and so only the value 256 is stored into the cell.

Is it possible to prevent the cut of the zeros?

Best regards & Thanks in advance

Here is a part of may code:

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = gv_content

IMPORTING

buffer = gv_xtext.

  • attach the first file

conv_out->convert( exporting data = gv_xtext ).

cl_wd_runtime_services=>attach_file_to_response(

i_filename = 'file1.XLS'

i_content = gv_xtext

i_mime_type = 'application/msexcel'

i_in_new_window = abap_true

i_inplace = abap_true ).

Accepted Solutions (0)

Answers (1)

Answers (1)

TomVanDoo
Active Contributor
0 Kudos

you could add an apostrophe ' in front of all fields that you want exported as a text.

this will ensure no truncating is done.

it's excel that does the shifting, so you can't really interfere from the SAP side