Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issue in cell format when exporting data to excel

Former Member
0 Likes
1,368

Hello there,

I have an ABAP program that selects data from tables into an internal table and writes the data in CSV (excel) file.

I have a very weird issue when writing the file: The data is written properly, though the dates in my data, which is written in yyyymmdd format, has different cell format in the csv file itself. I'll expain:

Let's say I've written into CSV file a table with name and birthdate, and I have 2000 records. From record 1 to 1475, when I right-click on the date cells in those lines, and choose "cell format", I can see it's in "general" format. From line 1476 on, when I do that I see that the date cells are in format of "custom" with pattern 'yyyymmdd'.

I want all the cells to be "general". How do I do that?

Thanks in advance

6 REPLIES 6
Read only

kabil_g
Active Participant
0 Likes
1,225

Hi Daniel,

Try using these Function Module......................

Before filling final internal table write those condition.................................

Data:  gv_date   TYPE mch1-vfdat,

         gv_vdate(10) TYPE c.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

       EXPORTING

         date_internal            = gv_date

       IMPORTING

         date_external            = gv_vdate

       EXCEPTIONS

         date_internal_is_invalid = 1

         OTHERS                   = 2.

     IF sy-subrc <> 0.

* Implement suitable error handling here

     ENDIF.

Read only

Former Member
0 Likes
1,225

Hello kabil,

I still want the date to be written as yyyymmdd format, but that the cell type will be "general" in excel.

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,225

Hi,

Try to create the output as YYYY-MM-DD .

Regards.

Read only

Former Member
0 Likes
1,225

Hi Daniel,

Try using the FM 'DATE_CONVERT_TO_FACTORYDATE'..

Regards,

SriLalitha.

Read only

Former Member
0 Likes
1,225

Try to pass date as string.

As date which appears in internal table might be different and internal table filed type should not be date.

while outputting to Excel if you passfrom internal table which is having Date as string type will send data in your requirement format.

Thanks

Naveen

Read only

Former Member
0 Likes
1,225

Note to all.

OP wants to set a cell property of CSV file. This can't be done because CSV format does not support cell properties.

However date data can be sent to CSV in a way that is not recognized by Microsoft Excel as a date.

Different ways to get around it can be found by searching.

/.