Skip to Content
avatar image
Former Member

Export to Excel - leading zeros problem


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' ).



text = gv_content


buffer = gv_xtext.

  • attach the first file

conv_out->convert( exporting data = gv_xtext ).


i_filename = 'file1.XLS'

i_content = gv_xtext

i_mime_type = 'application/msexcel'

i_in_new_window = abap_true

i_inplace = abap_true ).

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Sep 03, 2008 at 08:49 AM

    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

    Add comment
    10|10000 characters needed characters exceeded