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

Excel Download problem

Former Member
0 Likes
1,211

hi I am using GUI_DOWNLOAD to download an internal table to an excel sheet

This works fine... I want to have the field cells with their length according to their field length in Internal table

Presently the field cells are shrunk..

Can you please tell me how to do this...

9 REPLIES 9
Read only

Former Member
0 Likes
1,171

Hi,

GUI_DOWNLOAD saves itab data in TAB delimited format.

Excel just displays them in each cell.

You can check this thread for downloading data in formatted Excel.

Reward points if helpful.

Regards,

Basu.

Read only

Former Member
0 Likes
1,171

hi,

while appending the data in to the internal table after every field to append ',' also so that every field will sit in separate cell in the excel sheet when u use gui_download.

Read only

0 Likes
1,171

hi,

data:

f_comma(1) TYPE c VALUE ',',

f_quotes(1) TYPE c VALUE '"'.

CONCATENATE f_quotes 'Company' f_quotes f_comma

f_quotes 'Asset' f_quotes f_comma

f_quotes 'Asset' f_quotes f_comma

f_quotes 'Cost' f_quotes f_comma

f_quotes 'Asset' f_quotes f_comma

f_quotes 'Inventory' f_quotes f_comma

f_quotes 'Description' f_quotes f_comma

f_quotes 'Capitalized' f_quotes f_comma

f_quotes 'Depreciation' f_quotes f_comma

f_quotes 'Useful Life' f_quotes f_comma

f_quotes 'Useful Life' f_quotes f_comma

f_quotes 'Depreciation' f_quotes f_comma

f_quotes 'Acquisition' f_quotes f_comma

f_quotes 'Current Month' f_quotes f_comma

f_quotes 'YTD' f_quotes f_comma

f_quotes 'Accumulated' f_quotes f_comma

f_quotes 'Net Book Value' f_quotes f_comma

INTO i_file_rec.

APPEND i_file_rec.

CLEAR i_file_rec.

in this way u append the data in the internal table and u pass that internal table in that gui_download.

Read only

Former Member
0 Likes
1,171

Hi,

try to use the FM's TEXT_CONVERT_XLS_TO_SAP or ALSM_EXCEL_TO_INTERNAL_TABLE .

thease are convert excel to Internal table formet.

regards

Read only

Former Member
0 Likes
1,171

Hi

This question is still open, I remember having seen this issue some day on SDN but I am not able to find it

If you can tell me I shall award points

Read only

0 Likes
1,171

i think for this you have to go by OLE concept here i am giving you a sample code it may help you...


TYPE-POOLS : SLIS,OLE2.
TABLES : MARA,MARC,MAKT.
DATA : V_EXCEL TYPE OLE2_OBJECT, " Excel object
       V_CELL TYPE OLE2_OBJECT, " cell
       V_FONT TYPE OLE2_OBJECT, " font
       V_PAGE TYPE OLE2_OBJECT,
       V_PAGNO TYPE OLE2_OBJECT.


DATA : IRSTRUCINFO LIKE RSTRUCINFO OCCURS 0 WITH HEADER LINE.

DATA : COLNO TYPE I,
       CT TYPE I.

data : P_PROG LIKE sy-repid.

DATA : BEGIN OF ITAB OCCURS 0,
       MATNR LIKE MARA-MATNR,
       WERKS LIKE MARC-WERKS,
       EKGRP LIKE MARC-EKGRP,
       MTART LIKE MARA-MTART,
       MATKL LIKE MARA-MATKL,
       MAKTX LIKE MAKT-MAKTX,
       END OF ITAB.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
start-of-selection.

SELECT A~MATNR B~WERKS B~EKGRP A~MTART A~MATKL C~MAKTX INTO TABLE ITAB FROM
                       MARA AS A INNER JOIN MARC  AS B ON A~MATNR = B~MATNR
         INNER JOIN MAKT AS C ON A~MATNR = C~MATNR WHERE A~MATNR IN S_MATNR.
P_PROG = SY-REPID.

CALL FUNCTION 'GET_COMPONENT_LIST'
  EXPORTING
    PROGRAM    = P_PROG
    FIELDNAME  = 'ITAB'
  TABLES
    COMPONENTS = IRSTRUCINFO.

CREATE OBJECT V_EXCEL 'EXCEL.APPLICATION'.

SET PROPERTY OF V_EXCEL 'Visible' = 1.
CALL METHOD OF V_EXCEL 'Workbooks' = V_PAGE.

CALL METHOD OF V_PAGE 'Add' = V_PAGNO.

DATA : HEAD(3) TYPE N VALUE '1',
       EX_HEADING(25).

CLEAR : COLNO.
LOOP AT IRSTRUCINFO.

  COLNO = SY-TABIX.
  CALL METHOD OF V_EXCEL 'Cells' = V_CELL EXPORTING #1 = 1 #2 = COLNO.

  SET PROPERTY OF V_CELL 'Value' = IRSTRUCINFO-COMPNAME.
  GET PROPERTY OF V_CELL 'Font' = V_FONT.
  SET PROPERTY OF V_CELL 'Columnwidth' = IRSTRUCINFO-OLEN.
  SET PROPERTY OF V_FONT 'Bold' = 1 .
  SET PROPERTY OF V_FONT 'ColorIndex' = 5.
  GET PROPERTY OF V_CELL 'Interior' = V_FONT.
*SET PROPERTY OF V_FONT 'Color' = 16713413.
  SET PROPERTY OF V_FONT 'Color' = 16711624.
ENDLOOP.

CLEAR COLNO.
LOOP AT IRSTRUCINFO.
  COLNO = SY-TABIX.
  CALL METHOD OF V_EXCEL 'Cells' = V_CELL EXPORTING #1 = 2 #2 = COLNO.
  SET PROPERTY OF V_CELL 'Value' = IRSTRUCINFO-OLEN .
  GET PROPERTY OF V_CELL 'Font' = V_FONT.
  SET PROPERTY OF V_FONT 'ColorIndex' = 13.
  SET PROPERTY OF V_FONT 'Bold' = 1 .
  SET PROPERTY OF V_CELL 'Columnwidth' = IRSTRUCINFO-OLEN.
  GET PROPERTY OF V_CELL 'Interior' = V_FONT.
  SET PROPERTY OF V_FONT 'Color' =  16711428.

  CLEAR : COLNO.

ENDLOOP.
CT = 2.
LOOP AT ITAB.

    ct = ct + 1.
      CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 1.
      SET PROPERTY OF V_CELL 'Value' = ITAB-matnr.

      CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 2.
      SET PROPERTY OF V_CELL 'Value' = ITAB-WERKS.

      CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 3.
      SET PROPERTY OF V_CELL 'Value' = ITAB-EKGRP.

     CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 4.

      SET PROPERTY OF V_CELL 'Value' = ITAB-MTART.

      CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 5.
      SET PROPERTY OF V_CELL 'Value' = ITAB-MATKL.


      CALL METHOD OF V_EXCEL 'Cells' = V_CELL
        EXPORTING
        #1 = ct
        #2 = 6.
      SET PROPERTY OF V_CELL 'Value' = ITAB-MAKTX.

      CLEAR ITAB.

ENDLOOP.

regards

shiba dutta

Read only

Former Member
0 Likes
1,171

Take a look at the examples of using the XXL_SIMPLE_API and XXL_FULL_API function modules.

See programs XXLSTEST and XXLFTEST in the SE38 Controls examples.

Andrew

Read only

Former Member
0 Likes
1,171

hi,

Check this code it will help u.

PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:\tmp\test.xls'.

DATA: t100_Lines TYPE STANDARD TABLE OF t001 WITH DEFAULT KEY.

SELECT * FROM t001 INTO TABLE t100_Lines.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

i_filename = p_file

TABLES

i_tab_sap_data = t100_Lines.

Rewards points if it is useful.

Read only

Former Member
0 Likes
1,171

that was a weird question from me.. we cant do that