Skip to Content
avatar image
Former Member

[abap2xlsx] Get cell value with cell style

Hello,

I'm trying to read the value of an excel cell. The cell has a date style and I use the following code:

lo_worksheet->get_cell( EXPORTING ip_column = lv_col_act ip_row = lv_row_act IMPORTING ep_value = DATA(lv_excel_value) ep_style = DATA(lv_style) ).

Instead of getting the excel value (for example "20.07.2017") I'm getting only a number and the lv_style variable is filled.

How do I get the real excel value for cells with a style?

Thanks in advance.

Best regards

Daniel

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 02, 2017 at 06:08 PM

    There is the method ZCL_EXCEL_COMMON=>EXCEL_STRING_TO_DATE which converts the Excel value into an ABAP Date variable (type D).

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2017 at 03:35 PM

    That is the real cell value, Excel stores dates & times as serial numbers, The style just tells Excel to display it in date format. If you change the cells in Excel to use general then you will see the same numbers.

    If you convert them to ABAP dates, be aware of a little featurebug if using an old reference date. Here's a blog describing the issue: Link

    Add comment
    10|10000 characters needed characters exceeded