<?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: excel problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419559#M1409096</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is some code for autofit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that LV_AUTOFIT contains the column names&lt;/P&gt;&lt;P&gt;eg: B:D will apply the autofit on columns B, C and D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

* autofit - applying autofit
    call method of excel 'Columns' = h_columns
      exporting
      #1 = lv_autofit.

    get property of h_columns 'EntireColumn' = h_entirecol.
    set property of h_entirecol 'Autofit' = 1.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2009 03:48:38 GMT</pubDate>
    <dc:creator>former_member189059</dc:creator>
    <dc:date>2009-11-25T03:48:38Z</dc:date>
    <item>
      <title>excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419555#M1409092</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; first problem :&lt;/P&gt;&lt;P&gt;in the selection screen ,the user wants to choose the path (write it down as parameter field) that the excel is going to be saved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;second prob:  i want the cells of hte file to be autofitted,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is a part of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code. And please - one question per thread.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Nov 24, 2009 11:51 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2009 16:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419555#M1409092</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-24T16:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419556#M1409093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There you go.... One more like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First learn how to post code in SDN then ask a question or post question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am sure, you wont get any answers for this as it is not readable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question to you..... Can you read your own post?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This kind of post kills the interest of people who are ready to answer yout question&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2009 16:51:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419556#M1409093</guid>
      <dc:creator>former_member191735</dc:creator>
      <dc:date>2009-11-24T16:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419557#M1409094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok you are right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;parameters: pa_file like rlgrap-filename
 default 'C:\name.xls'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: w_lines TYPE p DECIMALS 0.
  DESCRIBE TABLE itab LINES w_lines.
  IF w_lines &amp;gt; 0.
    CREATE OBJECT application 'excel.application'.
    SET PROPERTY OF application 'visible' = 1.
    CALL METHOD OF application 'Workbooks' = workbook.
CALL METHOD OF workbook 'Add'.

    CALL METHOD OF application 'Worksheets' = sheet
      EXPORTING
        #1 = 1.
        SET PROPERTY OF sheet 'Name' = 'Damages'.
    CALL METHOD OF sheet 'Activate'.

 call method of application 'RANGE' = gs_range
  exporting #1 = 'A1:Z1'.
  set property of gs_range 'HORIZONTALALIGNMENT' = 3.

  call method of gs_range 'FONT' = gs_font.
  set property of gs_font 'BOLD' = 1.
*-&amp;gt; Find 1st empty cell of column 1
  data w_content(10) type c.
***
  w_lin = 2. 
  do 10000 times.
    CALL METHOD OF application 'Cells' = cells
      EXPORTING
        #1 = w_lin      " line
        #2 = 1.          " column
    clear w_content.
    GET PROPERTY OF cells 'Value' = w_content .
    if w_content = ' '.
      exit.
    else.
      w_lin = w_lin + 1.
    endif.
  enddo.
    CLEAR: w_index.
    w_lin = w_lin - 1.

    LOOP AT itab.


      CALL METHOD OF application 'Cells' = cells
        EXPORTING
          #1 = w_index      " line
          #2 = 1.           " column
      SET PROPERTY OF cells 'Value' = itab-vertran .


 CALL METHOD OF APPLICATION 'Save'
    EXPORTING
*    #1 = p_file

        #1 =  pa_file.
*        #2 = pa_file."filename
    "fileFormat

*  Closes excel window, data is lost if not saved
  SET PROPERTY OF application 'visible' = 1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2009 17:03:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419557#M1409094</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-24T17:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419558#M1409095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is some code to save the file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          get property of application 'ActiveSheet' = sheet.
          call method of sheet 'SaveAs'
            exporting
              #1 = pa_file        "filename
              #2 = 1.                     "fileFormat

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2009 03:46:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419558#M1409095</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2009-11-25T03:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419559#M1409096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is some code for autofit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that LV_AUTOFIT contains the column names&lt;/P&gt;&lt;P&gt;eg: B:D will apply the autofit on columns B, C and D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

* autofit - applying autofit
    call method of excel 'Columns' = h_columns
      exporting
      #1 = lv_autofit.

    get property of h_columns 'EntireColumn' = h_entirecol.
    set property of h_entirecol 'Autofit' = 1.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2009 03:48:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419559#M1409096</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2009-11-25T03:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419560#M1409097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you . now the file is saved. but i cannot fix the autofit problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2009 08:42:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419560#M1409097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-25T08:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419561#M1409098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The word 'excel' in the above code refers to the excel.application object&lt;/P&gt;&lt;P&gt;I guess the variable used in your case is 'application'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So change that accordingly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2009 08:50:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419561#M1409098</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2009-11-25T08:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: excel problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419562#M1409099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i had changed it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;call method of application 'Columns' = h_columns
      exporting
      #1 = lv_autofit.

    get property of h_columns 'EntireColumn' = h_entirecol.
    set property of h_entirecol 'Autofit' = 1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i dont understand the lv_autofit.  where and how i declare the columns?&lt;/P&gt;&lt;P&gt;i put this code above the "save" code.&lt;/P&gt;&lt;P&gt;thank you again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ok i tried this and is ok&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code}call method of application 'Columns' = h_columns&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;      #1 = 'A:Z'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    get property of h_columns 'EntireColumn' = h_entirecol.&lt;/P&gt;&lt;P&gt;    set property of h_entirecol 'Autofit' = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: antonis nezos on Nov 25, 2009 10:14 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2009 09:05:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-problem/m-p/6419562#M1409099</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-25T09:05:44Z</dc:date>
    </item>
  </channel>
</rss>

