<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: GUI_DOWNLOAD - Column Width in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465409#M1251871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Vishnu Paval:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this kind of data in internal table:&lt;/P&gt;&lt;P&gt;001 002 003 004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with this title in their header:&lt;/P&gt;&lt;P&gt;Title1 Title2 Title3 Title4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After Gui dowload i'm required to have a excel file with this output:&lt;/P&gt;&lt;P&gt;Title1 Title2 Title3 Title4 &lt;/P&gt;&lt;P&gt;  001    002   003    004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to know if its possible to set each of the column size according to my header width.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Apr 2009 03:57:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-14T03:57:13Z</dc:date>
    <item>
      <title>GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465405#M1251867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement to use gui download but im having problem in its column width, i want the excel to have a column width same as the title of the column, is this possible (to have different column width in the output excel file)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 03:38:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465405#M1251867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-14T03:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465406#M1251868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;question is not clear!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 03:40:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465406#M1251868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-14T03:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465407#M1251869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this,may be it work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) To change the column width of one particular cell&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT h_excel 'EXCEL.APPLICATION' NO FLUSH.&lt;/P&gt;&lt;P&gt;SET PROPERTY OF h_excel 'Visible' = 1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL METHOD OF h_excel 'Cells' = h_zl EXPORTING #1 = 1 #2 = 1. "Here we are changing 1st R 1st C&lt;/P&gt;&lt;P&gt;SET PROPERTY OF h_zl 'Columnwidth' = .. "your data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)To change the column width of range of cells&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD OF h_excel 'Cells' = h_zl1 EXPORTING #1 = 1 #2 = 1."1st row 1st column&lt;/P&gt;&lt;P&gt;CALL METHOD OF h_excel 'Cells' = h_zl2 EXPORTING #1 = 100 #2 = 1. "100th row first column&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL METHOD OF h_excel 'Range' = h_range&lt;/P&gt;&lt;P&gt;EXPORTING #1 = h_zl1 #2 = h_zl2. "This mmeans that first column of 100 records&lt;/P&gt;&lt;P&gt;SET PROPERTY OF h_range 'Columnwidth' = ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:       H_COLUMNS     TYPE OLE2_OBJECT.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL METHOD OF EXCEL 'Columns' = H_COLUMNS&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    #1 = 'A:E'.  " which columns you want to choose&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;SET PROPERTY OF h_columns 'ColumnWidth' = 17.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 03:42:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465407#M1251869</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-14T03:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465408#M1251870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the below mentioned sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;




INCLUDE ole2incl.                       "include used for providing classes used for using create object for creating application and worksheets
DATA: application TYPE ole2_object,
       workbook TYPE ole2_object,
       sheet TYPE ole2_object,
       cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.

*DATA: BEGIN OF itab1 OCCURS 0, first_name(10), END OF itab1.
*DATA: BEGIN OF itab2 OCCURS 0, last_name(10), END OF itab2.
DATA: BEGIN OF itab3 OCCURS 0, formula(50), END OF itab3.
*


TABLES: vbap,mara.


TYPES: BEGIN OF itab,
       lifnr TYPE lfa1-lifnr,
       land1 TYPE lfa1-land1,
*       name1 TYPE lfa1-name1,
*       ort01 TYPE lfa1-ort01,
       END OF itab.



DATA: BEGIN OF itab2 OCCURS 0,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
END OF itab2.
 data : v_row type sy-tabix.

DATA: itab1 TYPE STANDARD TABLE OF itab WITH HEADER LINE.

DATA: IT_XLSTAB TYPE STANDARD TABLE OF ITAB ,
      WA_XLSTAB LIKE LINE OF IT_XLSTAB.

START-OF-SELECTION.

  SELECT lifnr land1 fROM lfa1  INTO CORRESPONDING FIELDS OF TABLE itab1 UP TO 5 ROWS.


  SELECT matnr
  ersda
  ernam
  FROM mara
  INTO CORRESPONDING FIELDS OF
  TABLE itab2 UP TO 5 ROWS.



************************************************************************
*START-OF-SELECTION
START-OF-SELECTION.

  CREATE OBJECT application 'excel.application'.
  SET PROPERTY OF application 'visible' = 1.
  CALL METHOD OF application 'Workbooks' = workbook.
  CALL METHOD OF workbook 'Add'.

* Create first Excel Sheet
  CALL METHOD OF application 'Worksheets' = sheet
                               EXPORTING #1 = 1.
  CALL METHOD OF sheet 'Activate'.
  SET PROPERTY OF sheet 'Name' = 'Sheet1'.
  clear v_row.
  LOOP AT itab1.
     v_row = sy-tabix.
      perform fill_cell  using  v_row 1  itab1-lifnr.
      perform fill_cell  using  v_row 2 itab1-land1.
  ENDLOOP.

* Create second Excel sheet
  CALL METHOD OF application 'Worksheets' = sheet
                               EXPORTING #1 = 2.
  SET PROPERTY OF sheet 'Name' = 'Sheet2'.
  CALL METHOD OF sheet 'Activate'.
  clear v_row.
  LOOP AT itab2.
     v_row = sy-tabix.

      perform fill_cell using  v_row 1 itab2-matnr.
      perform fill_cell using  v_row 2 itab2-ersda.
      perform fill_cell using  v_row 3 itab2-ernam.

  ENDLOOP.


* Save excel speadsheet to particular filename
  CALL METHOD OF sheet 'SaveAs'
                  EXPORTING #1 = 'c:\temp\excelgeet.xls'     "filename
                            #2 = 1.                          "fileFormat

*  Closes excel window, data is lost if not saved
  SET PROPERTY OF application 'visible' = 0.

*  call method of sheet 'CLOSE'
*
*  EXPORTING #1 = 'YES'.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; both the below coding closes the apllication permanently from the task manager also.
*&amp;amp;---------------------------------------------------------------------*

SET PROPERTY OF application 'DisplayAlerts' = 0.
   free OBJECT application.


**  call method of application 'QUIT'.
**
**  FREE OBJECT: APPLICATION,
**               SHEET.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fill_cell
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_1      text
*      --&amp;gt;P_V_COL  text
*      --&amp;gt;P_ITAB1_LIFNR  text
*----------------------------------------------------------------------*
form fill_cell  using row  col val.

    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = row  #2 = col.
    SET PROPERTY OF cells 'Value' = val.


endform.                    " fill_cell


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 03:47:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465408#M1251870</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-14T03:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465409#M1251871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Vishnu Paval:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this kind of data in internal table:&lt;/P&gt;&lt;P&gt;001 002 003 004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with this title in their header:&lt;/P&gt;&lt;P&gt;Title1 Title2 Title3 Title4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After Gui dowload i'm required to have a excel file with this output:&lt;/P&gt;&lt;P&gt;Title1 Title2 Title3 Title4 &lt;/P&gt;&lt;P&gt;  001    002   003    004&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to know if its possible to set each of the column size according to my header width.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 03:57:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465409#M1251871</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-14T03:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: GUI_DOWNLOAD - Column Width</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465410#M1251872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can set specific output length for your columns via wa_fieldcat-outputlen or by setting the lwa_layout-colwidth_optimize  to 'X' so that the system automatically adjusts the widht of your column depemding on the data .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2009 05:04:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gui-download-column-width/m-p/5465410#M1251872</guid>
      <dc:creator>dev_parbutteea</dc:creator>
      <dc:date>2009-04-14T05:04:56Z</dc:date>
    </item>
  </channel>
</rss>

