<?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: into excel sheet with multiple tabs in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415861#M820417</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sashi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes , It is,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run below report .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZP_EXCEL .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; Report ZP_EXCEL *&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;include ole2incl.&lt;/P&gt;&lt;P&gt;data: application type ole2_object,&lt;/P&gt;&lt;P&gt;workbook type ole2_object,&lt;/P&gt;&lt;P&gt;sheet type ole2_object,&lt;/P&gt;&lt;P&gt;cells type ole2_object,&lt;/P&gt;&lt;P&gt;sheets TYPE ole2_object.&lt;/P&gt;&lt;P&gt;constants: row_max type i value 256.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data index type i.&lt;/P&gt;&lt;P&gt;data : det type ref to CL_ABAP_structDESCR,&lt;/P&gt;&lt;P&gt;       wa like line of det-&amp;gt;components.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of i_finaltab occurs 0,&lt;/P&gt;&lt;P&gt;       Col1 type i,&lt;/P&gt;&lt;P&gt;       col2 type i,&lt;/P&gt;&lt;P&gt;       col3 type i,&lt;/P&gt;&lt;P&gt;       col4 type i,&lt;/P&gt;&lt;P&gt;      end of i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data : count type i,&lt;/P&gt;&lt;P&gt;        v_excel_count(3), " type i value 1,&lt;/P&gt;&lt;P&gt;        sheet_name(15)  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*START-OF-SELECTION&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do 50 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  i_finaltab-col2 = 5 * count.&lt;/P&gt;&lt;P&gt;  i_finaltab-col3 = 10 * count.&lt;/P&gt;&lt;P&gt;  i_finaltab-col4 = 20 * count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  move : count to i_finaltab-col1.&lt;/P&gt;&lt;P&gt;  append  i_finaltab.&lt;/P&gt;&lt;P&gt;  clear i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create object application 'excel.application'.&lt;/P&gt;&lt;P&gt;set property of application 'visible' = 1.&lt;/P&gt;&lt;P&gt;call method of application 'Workbooks' = workbook.&lt;/P&gt;&lt;P&gt;call method of workbook 'Add'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Create first Excel Sheet&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;call method of application 'Worksheets' = sheet&lt;/P&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;P&gt; #1 = 1.&lt;/P&gt;&lt;P&gt;  call method of sheet 'Activate'.&lt;/P&gt;&lt;P&gt;  set property of sheet 'Name' = 'EXCEL0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     count = 1.&lt;/P&gt;&lt;P&gt;     index = row_max * ( count - 1 ) + 1.&lt;/P&gt;&lt;P&gt;     perform header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   count = count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if count LE 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index = row_max * ( count - 1 ) + 1. " 1 - column name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    v_excel_count =  v_excel_count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   CALL METHOD OF application 'Sheets' = sheets.&lt;/P&gt;&lt;P&gt;   CALL METHOD OF sheets 'Add'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        concatenate 'EXCEL' v_excel_count into sheet_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     clear count.&lt;/P&gt;&lt;P&gt;     count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     call method of application 'Worksheets' = sheet&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;      #1 = 1.&lt;/P&gt;&lt;P&gt;      set property of sheet 'Name' = sheet_name.&lt;/P&gt;&lt;P&gt;      call method of sheet 'Activate'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index = row_max * ( count - 1 ) + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      perform header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index = row_max * ( count - 1 ) + 1. " 1 - column name&lt;/P&gt;&lt;P&gt;      call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;       #1 = index.&lt;/P&gt;&lt;P&gt;     set property of cells 'Value' = i_finaltab-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;       #1 = index.&lt;/P&gt;&lt;P&gt;      set property of cells 'Value' = i_finaltab-col2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  header_details&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;det ?= cl_abap_typedescr=&amp;gt;describe_by_DATA( i_finaltab ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at det-&amp;gt;components into wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;  exporting&lt;/P&gt;&lt;P&gt;  #1 = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  set property of cells 'Value' = wa-name.&lt;/P&gt;&lt;P&gt;  index = index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " header_details&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward if useful...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Feb 2008 05:47:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-18T05:47:27Z</dc:date>
    <item>
      <title>into excel sheet with multiple tabs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415857#M820413</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;Is it possible to download data into an excel sheet with multiple tabs &lt;/P&gt;&lt;P&gt;using an ABAP program? &lt;/P&gt;&lt;P&gt;Still hoping someone might have faced this and has found some solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2008 11:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415857#M820413</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-08T11:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: into excel sheet with multiple tabs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415858#M820414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure, you can use OLE programming for that.&lt;/P&gt;&lt;P&gt;&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;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2008 11:11:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415858#M820414</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-08T11:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: into excel sheet with multiple tabs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415859#M820415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     1. create several text files one for each sheet. &lt;/P&gt;&lt;P&gt;     2. create an excel macro where you a. insert a new sheet, and b. upload &lt;/P&gt;&lt;P&gt;     a file into it (may be you repeat a and b several times &lt;/P&gt;&lt;P&gt;     3. research on the net looking for running excel macros from sap (there &lt;/P&gt;&lt;P&gt;     are at least two pages which tell you how to do it using ole2). &lt;/P&gt;&lt;P&gt;     4. put 1 to 3 together and you'll have what you're looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Chaitanya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Feb 2008 12:24:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415859#M820415</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-16T12:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: into excel sheet with multiple tabs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415860#M820416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below program can give you some lead and use accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
INCLUDE ole2incl.
DATA: application TYPE ole2_object,
       workbook TYPE ole2_object,
       sheet TYPE ole2_object,
       sheets TYPE ole2_object,
       cells TYPE ole2_object.
CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.

TYPES: BEGIN OF t_data,
         sheet_no TYPE i,
         col1(20) TYPE c,
         col2(20) TYPE c,
       END OF t_data.
DATA: it_data TYPE STANDARD TABLE OF t_data,
      wa_data TYPE t_data.

DATA: g_sheet TYPE i VALUE 1,
      g_row TYPE i,
      g_col TYPE i.


***********************************************************************
*
*START-OF-SELECTION
START-OF-SELECTION.

  PERFORM populate_data.

  CREATE OBJECT application 'excel.application'.
  SET PROPERTY OF application 'visible' = 1.
  CALL METHOD OF application 'Workbooks' = workbook.

  CALL METHOD OF workbook 'Add' = workbook.
  CALL METHOD OF workbook 'Sheets' = sheets.

  LOOP AT it_data INTO wa_data.

    ON CHANGE OF wa_data-sheet_no.
      IF wa_data-sheet_no &amp;gt; 3.
        CALL METHOD OF sheets 'Add' = sheet.
        SET PROPERTY OF sheets 'active' = 1.
        SET PROPERTY OF sheet 'Name' = wa_data-sheet_no.
      ENDIF.

      CALL METHOD OF workbook 'worksheets' = sheet NO FLUSH
        EXPORTING
          #1 = g_sheet.
      SET PROPERTY OF sheet 'name' = wa_data-sheet_no.

      g_sheet = g_sheet + 1.
      g_row = 0.
    ENDON.

    g_row = g_row + 1. g_col = 1.
    CALL METHOD OF sheet 'cells' = cells
      EXPORTING
        #1 = g_row
        #2 = g_col.

    SET PROPERTY OF cells 'value' = wa_data-col1.
    g_col = g_col + 1.

    CALL METHOD OF sheet 'cells' = cells
      EXPORTING
        #1 = g_row
        #2 = g_col.

    SET PROPERTY OF cells 'value' = wa_data-col2.
  ENDLOOP.

* Save excel speadsheet to particular filename
  CALL METHOD OF sheet 'SaveAs'
                  EXPORTING #1 = 'c:\exceldoc1.xls'     "filename
                            #2 = 1.
*ileFormat

  CALL METHOD OF sheet 'Close'
                 EXPORTING #1 = 'c:\exceldoc1.xls'     "filename
                           #2 = 1.
  IF sy-subrc EQ 0.
    EXIT.
  ENDIF.

*  Closes excel window, data is lost if not saved
  SET PROPERTY OF application 'visible' = 0.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  populate_data
*&amp;amp;---------------------------------------------------------------------*
FORM populate_data .

  DATA: l_sheet TYPE n.


  DO 5 TIMES.
    l_sheet = l_sheet + 1.
    MOVE l_sheet TO wa_data-sheet_no.

    CONCATENATE: l_sheet '-row1-col1' INTO wa_data-col1,
                 l_sheet '-row1-col2' INTO wa_data-col2.
    APPEND wa_data TO it_data.

    CONCATENATE: l_sheet '-row2-col1' INTO wa_data-col1,
                 l_sheet '-row2-col2' INTO wa_data-col2.
    APPEND wa_data TO it_data.

    CONCATENATE: l_sheet '-row3-col1' INTO wa_data-col1,
                 l_sheet '-row3-col2' INTO wa_data-col2.
    APPEND wa_data TO it_data.

    CONCATENATE: l_sheet '-row4-col1' INTO wa_data-col1,
                 l_sheet '-row4-col2' INTO wa_data-col2.
    APPEND wa_data TO it_data.

  ENDDO.

ENDFORM.                    " populate_data
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that this can be quite slow process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2008 05:18:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415860#M820416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-18T05:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: into excel sheet with multiple tabs</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415861#M820417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sashi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes , It is,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run below report .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZP_EXCEL .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp; Report ZP_EXCEL *&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;include ole2incl.&lt;/P&gt;&lt;P&gt;data: application type ole2_object,&lt;/P&gt;&lt;P&gt;workbook type ole2_object,&lt;/P&gt;&lt;P&gt;sheet type ole2_object,&lt;/P&gt;&lt;P&gt;cells type ole2_object,&lt;/P&gt;&lt;P&gt;sheets TYPE ole2_object.&lt;/P&gt;&lt;P&gt;constants: row_max type i value 256.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data index type i.&lt;/P&gt;&lt;P&gt;data : det type ref to CL_ABAP_structDESCR,&lt;/P&gt;&lt;P&gt;       wa like line of det-&amp;gt;components.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of i_finaltab occurs 0,&lt;/P&gt;&lt;P&gt;       Col1 type i,&lt;/P&gt;&lt;P&gt;       col2 type i,&lt;/P&gt;&lt;P&gt;       col3 type i,&lt;/P&gt;&lt;P&gt;       col4 type i,&lt;/P&gt;&lt;P&gt;      end of i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data : count type i,&lt;/P&gt;&lt;P&gt;        v_excel_count(3), " type i value 1,&lt;/P&gt;&lt;P&gt;        sheet_name(15)  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*START-OF-SELECTION&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do 50 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  i_finaltab-col2 = 5 * count.&lt;/P&gt;&lt;P&gt;  i_finaltab-col3 = 10 * count.&lt;/P&gt;&lt;P&gt;  i_finaltab-col4 = 20 * count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  move : count to i_finaltab-col1.&lt;/P&gt;&lt;P&gt;  append  i_finaltab.&lt;/P&gt;&lt;P&gt;  clear i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create object application 'excel.application'.&lt;/P&gt;&lt;P&gt;set property of application 'visible' = 1.&lt;/P&gt;&lt;P&gt;call method of application 'Workbooks' = workbook.&lt;/P&gt;&lt;P&gt;call method of workbook 'Add'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Create first Excel Sheet&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;call method of application 'Worksheets' = sheet&lt;/P&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;P&gt; #1 = 1.&lt;/P&gt;&lt;P&gt;  call method of sheet 'Activate'.&lt;/P&gt;&lt;P&gt;  set property of sheet 'Name' = 'EXCEL0'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     count = 1.&lt;/P&gt;&lt;P&gt;     index = row_max * ( count - 1 ) + 1.&lt;/P&gt;&lt;P&gt;     perform header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_finaltab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   count = count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if count LE 6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index = row_max * ( count - 1 ) + 1. " 1 - column name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    v_excel_count =  v_excel_count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   CALL METHOD OF application 'Sheets' = sheets.&lt;/P&gt;&lt;P&gt;   CALL METHOD OF sheets 'Add'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        concatenate 'EXCEL' v_excel_count into sheet_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     clear count.&lt;/P&gt;&lt;P&gt;     count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     call method of application 'Worksheets' = sheet&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;      #1 = 1.&lt;/P&gt;&lt;P&gt;      set property of sheet 'Name' = sheet_name.&lt;/P&gt;&lt;P&gt;      call method of sheet 'Activate'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index = row_max * ( count - 1 ) + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      perform header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      count =  count + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index = row_max * ( count - 1 ) + 1. " 1 - column name&lt;/P&gt;&lt;P&gt;      call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;       #1 = index.&lt;/P&gt;&lt;P&gt;     set property of cells 'Value' = i_finaltab-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;       #1 = index.&lt;/P&gt;&lt;P&gt;      set property of cells 'Value' = i_finaltab-col2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    index =  index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;     #1 = index.&lt;/P&gt;&lt;P&gt;    set property of cells 'Value' = i_finaltab-col4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  header_details&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; --&amp;gt;  p1        text&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;lt;--  p2        text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form header_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;det ?= cl_abap_typedescr=&amp;gt;describe_by_DATA( i_finaltab ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at det-&amp;gt;components into wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  call method of sheet 'Cells' = cells&lt;/P&gt;&lt;P&gt;  exporting&lt;/P&gt;&lt;P&gt;  #1 = index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  set property of cells 'Value' = wa-name.&lt;/P&gt;&lt;P&gt;  index = index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " header_details&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward if useful...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2008 05:47:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/into-excel-sheet-with-multiple-tabs/m-p/3415861#M820417</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-18T05:47:27Z</dc:date>
    </item>
  </channel>
</rss>

