Writing in to multiple sheets in Excel file based on input condition

Hi All Experts,
i need to write in to multiple sheets in one Excel file output.
is it possible with UTL_FILE ? or Any options there in Oracle to do this ?
Can anyone please suggest me on this.
Thanks,
Ravi

I have seen all of them they are all just simple SQL pulls from database in to Excel file..No, definitely not
My requirement is i need to write in to one single Excel file with MULTIPLE sheets based on input condition-> [xml_spreadsheet|http://matzberger.de/oracle/spreadsheet-en.html]
so for each parameter need to write into separate sheet in one Excel File..-> [xml_spreadsheet|http://matzberger.de/oracle/spreadsheet-en.html]
I hope you understand my problem atleast now...I think I understood your problem at first sight.
If you simply want to throw 2 queries at the package and get back an Excel file with 2 worksheets you just have to look at the first page of the [tutorial |http://matzberger.de/oracle/spreadsheet-tut-en.html]. Half way down the page there's an example.
If you want a special formatting then you can do this too, it's described step by step.
Regards
Marcus

Similar Messages

  • Export SQL Server Table into Multiple Sheets in Excel

    I'm trying to understand the example here.
    http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
    Basically, I'm up to step #5.
    5. Data Flow Task to populate the created sheet with data for that subject. The Data Flow looks like below
    I don't understand this part.  Has anyone worked with this sample before?  Has anyone gotten this to work?  I'm trying to learn SSIS better, but I'm finding it hard to get started with this stuff.  I guess if I get a couple projects under
    my belt, I'll be fine.  The hardest part is getting started.
    If anyone feels really ambitions today, maybe you can assist me with two other projects as well.
    #1)
    http://visakhm.blogspot.in/2011/12/simulating-file-watcher-task-in-ssis.html
    #2)
    http://sqlage.blogspot.in/2013/12/ssis-read-multiple-sheets-from-excel.html
    http://beyondrelational.com/modules/24/syndicated/398/Posts/18163/ssis-how-to-loop-through-multiple-excel-sheets-and-load-them-into-a-sql-table.aspx
    I'd greatly appreciate any help I can get with this.
    Thanks!!
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Hi Ryguy72,
    The solution introduced in Visakh’s blog does work. I have written the detailed steps for you:
    1. Create an Excel file (Des.xls) as the destination file, rename the Sheet1 to “Excel Destination”, and add four columns: ID, Name, Subject, and Marks.
    2. Create an Object type variable Subject, a String type variable SheetName, and a String type variable WorkSheetQuery.
    3. Set the value of variable SheetName to “Excel Destination$”, and set the expression of variable WorkSheetQuery to:
    "CREATE TABLE `" + @[User::SheetName] + "` (
    `ID` Long,
    `Name` LongText,
    `Subject` LongText,
    `Marks` Long
    4. In the Execute SQL Task outside the Foreach Loop Container, set its General tab as follows:
    ResultSet: Full result set
    ConnectionType: OLE DB
    Connection: LocalHost.TestDB (e.g. an OLE DB Connection to the source SQL Server table)
    SQLSourceType: Direct input
    SQLStatement: SELECT DISTINCT [Subject] FROM [TestDB].[dbo].[DynamicExcelSheetDemo]
    5. In the Result Set tab of this Execute SQL Task, map result “0” to variable “User::Subject”.
    6. In the Collection page of the Foreach Loop Container, set the Enumerator option to “Foreach ADO Enumerator”, and set the “ADO object source variable” to “User::Subject”.
    7. In the Variable Mapping page of the container, map variable “User::SheetName” to index “0”.
    8. Create an OLE DB Connection Manager to connect to the destination Excel file. Choose the provider as Native OLE DB\Microsoft Jet 4.0 OLE DB Provider, specify the fully qualified path of the Excel file (such as C:\Temp\Des.xls), and set the Extended Properties
    option of the Connection Manager to “Excel 8.0”. Click “Test Connection” button to make sure the connection is established successfully.
    9. Set the General page of the Execute SQL Task inside the container as follows:
    ResultSet: None
    ConnectionType: OLE DB
    Connection: Des (e.g. the OLE DB Connection to the destination Excel file we create above)
    SQLSourceType: Variable
    SQLStatement: User::WorkSheetQuery
    10. In the Data Flow Task, add an OLE DB Source component, set the connection manager to “LocalHost.TestDB”, set “Data access mode” to “SQL command”, and set the “SQL command text” to:
    SELECT * FROM [TestDB].[dbo].[DynamicExcelSheetDemo] WHERE [Subject]=?
    11. Click the “Parameters…” button, and map Parameter0 to variable “User::SheetName”.
    12. Add an Excel Destination component, setup an Excel Connection Manager to the destination Excel file, set the data access mode to “Table name or view name variable”, and select variable name as “User::SheetName”. In this way, the OLE DB Provider can get
    the Excel metadata and enable us to finish the column mappings correctly.
    13. Since the Microsoft Jet 4.0 has only 32-bit driver, please make sure to set the Run64BitRuntime property of the IS project to False.
    In addition, please note that there will be one useless worksheets “Excel Destination” in the Excel file. We can remove them manually or use a Script Task to delete this worksheet programmatically (need to install .NET Programmability Support feature during
    Office installing).
    Regards,
    Mike Yin
    TechNet Community Support

  • How to export the data to Multiple sheet in Excel

    Hi,
    How can I export the data to multiple sheets in excel using Crystal Report XI.
    Thanks,
    Baski.
    Edited by: J_Baskaar on Mar 31, 2010 8:14 AM

    One of the 3rd-party Crystal report schedulers listed at http://www.kenhamady.com/bookmarks.html allows you to burst a report so that each group at level 1 becomes a separate worksheet inside a single workbook.

  • Data download to multiple sheets in Excel without using OLE

    Hi,
    Please let me know if it is possible to download data to multiple sheets in excel without using OLE method
    I am in SRM system and the OLE methods are not working
    Please share some sample code or reference links if any
    Thanks
    SekharJ
    Edited by: SekharJ on Sep 8, 2009 8:43 AM

    Here is my code
      LOOP AT it_final INTO wa_final.
        AT FIRST.
          l_ixml = cl_ixml=>create( ).
          l_document = l_ixml->create_document( ).
          l_element_flights  = l_document->create_simple_element(
                      name = 'PO_Details'
                      parent = l_document ).
        ENDAT.
        l_element_airline  = l_document->create_simple_element(
                    name = 'PO'
                    parent = l_element_flights  ).
        l_value = wa_final-object_id.
        l_rc = l_element_airline->set_attribute( name = 'Objectid' value =
                                                             l_value ).
        l_value = wa_final-description.
        l_rc = l_element_airline->set_attribute( name = 'Description' value =
                                                             l_value ).
        l_value = wa_final-number_int.
        l_rc = l_element_airline->set_attribute( name = 'Item' value =
                                                             l_value ).
        l_value = wa_final-description1.
        l_rc = l_element_airline->set_attribute( name = 'Description1' value =
                                                             l_value ).
        l_value = wa_final-quantity.
        l_rc = l_element_airline->set_attribute( name = 'Quantity' value =
                                                             l_value ).
        l_value = wa_final-capex.
        l_rc = l_element_airline->set_attribute( name = 'Capex' value =
                                                             l_value ).
        l_value = wa_final-ser_num.
        l_rc = l_element_airline->set_attribute( name = 'SerialNo' value =
                                                             l_value ).
        l_value = wa_final-plant.
        l_rc = l_element_airline->set_attribute( name = 'Plant' value =
                                                             l_value ).
        l_value = wa_final-loc.
        l_rc = l_element_airline->set_attribute( name = 'Location' value =
                                                             l_value ).
        l_value = wa_final-bundle.
        l_rc = l_element_airline->set_attribute( name = 'Bundle' value =
                                                             l_value ).
      ENDLOOP.
      l_streamfactory = l_ixml->create_stream_factory( ).
      l_ostream = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      l_renderer = l_ixml->create_renderer( ostream  = l_ostream
                                            document = l_document ).
      l_rc = l_renderer->render( ).
      l_xml_size = l_ostream->get_num_written_raw( ).
        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            bin_filesize = l_xml_size
            filename     = 'c:\temp\flights.xlsx'
            filetype     = 'BIN'
          CHANGING
            data_tab     = l_xml_table
          EXCEPTIONS
            OTHERS       = 24.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Edited by: SekharJ on Sep 8, 2009 12:04 PM
    Edited by: SekharJ on Sep 8, 2009 12:15 PM

  • Single iDOc to multiple files based on a condition

    Hi Friends
    need your help in one scenario which is something like this:
    there is one iDOC as the sender and this iDOC has to be mapped to files based on a condition means let us say if there is a particular field "R" in iDOC(WPDBBYY01) than it should go and create the file "ABC"
    and if the particlar field is P or G or M than it should create another 2 files named "XYZ" and "WUV" .
    Please guide me how can i put this condition ?
    Any help would be rewarded with points
    Thanks

    Have a single receiver and 2 inbound interfaces.
    So you will have 2 different mappings. In the first mappng source is IDOC and the target is file ABC.
    In the second mappping the source is IDOC and the target is 2 files XYZ and WUV.
    In Interface determination, add both the inbound interfaces and put the condition for each interface.
    Regards,
    Jaishankar

  • Include file based on if condition

    I was wondering if its possible to include a file (or display a file) based on a condition in JSPs.. for example:
    ----------Desired functionality----------------
    <%
    if (myconnection == null)
    // include/display login page
    else
    // display the main page
    %>
    I tried this.. Not working based on my condition... I get both the files displayed in one page..
    ----my code----
    <%
    if (DBcon.con == null)
    out.println("No connection");
    %>
    <%@ include file="Login.jsp"%>
    <%
    if (DBcon != null)
    out.println("connected");
    %>
    <%@ include file="Main.jsp" %>
    -NJU

    If you don't put a { after the if statement, then it's only going to execute the first line after it.  This is always the case, in JSP or otherwise.  Otherwise how would it know when to stop? 
    <%
    if (DBcon.con == null) {
       out.println("No connection");
    %>
    <%@ include file="Login.jsp"%>
    <%
    if (DBcon != null) {
       out.println("connected");
    %>
    <%@ include file="Main.jsp" %>
    <%
    %>

  • Upload data from multiple worksheets of excel file into SAP by using MIME?

    Hi all,
    I'm trying to getting the data from a multiple worksheet excel file by usin the MIME Repository.
    First of all i realizied it like [here|http://abap-explorer.blogspot.com/2008/12/upload-data-from-multiple-worksheets-of.html] in a normal ABAP Report.
    By trying to transfer the code to a WebDynpro Component, i get problems.
    With this part of code, because ActiveX is not allowed in our Webbrowser. So i have to find another solution to get the data from the excel file.
    CALL METHOD c_oi_container_control_creator=>get_container_control
    IMPORTING
    control = iref_control
    error   = iref_error
    I tried to rebuild this solution in webdynpro. But it dont works.
    So my next step was trying to Read the Excel sheet directly from MIME by getting the Content (XString).
    But there is no useful information Just a mix out of '######' and other symbols.
    By converting it into String the same problem.
    Maybe someone has an idea how to rebuild [this code|http://abap-explorer.blogspot.com/2008/12/upload-data-from-multiple-worksheets-of.html] in Webdynpro that it works correctly.
    Currently Im Using the Fileupload UI Element. All Works fine. I can Upload the Excel file to MIME Repository and i can open it from there.
    But i cant get the same clear informationen from the file, to write it later in a Database, like before without webdynpro.
    i hope someone can help me.
    Edited by: Sascha Baumann on Apr 20, 2009 4:28 PM

    You can't read the native binary Excel Format in server side ABAP.  The functions and classes that did this in Classic Dynpro used OLE Automation via the SAPGUI Control Framework to remotely control Excel to read the data.  Because in the browser you have no connection to the SAPGUI or are sandboxed inside the browser; the same functionality is not possible. 
    I would suggest that you look into saving the Excel file as a open, text format.  You might be able to use XML (although the Excel XML format can be complex) to support multiple sheets. You would have to build the logic yourself (using XSLT or the iXML parser) to process the XML format back into ABAP data.

  • How to create new Sheet in Excel file and write into it

    Hi to all, my requirement is this:
    I have an excel file (.xls) with multiple sheets (three sheets for precision: sheet1, sheet2 and sheet3).
    I must create in the same excel file new sheet, say sheet4, read data from sheet1, sheet2 and sheet3 and write them into sheet4.
    How to realize this in SSIS?
    Expecially, Is it possible to realize this in SSIS?
    thanks in advance.

    You need to create the sheet with the required metadata. There's no use creating blank sheet.
    Also metadata has to be fixed using a sample sheet prior to start of the package for setting the mapping. You may create a excel template for this purpose to just set the mapping at design time.
    At runtime pass actual excel sheet path for ExcelFilePath property of the source to point to correct file.
    Also the create table statement should include the same metadata info (columns)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    Hi, well it works fine! I have used a sample sheet prior to start of the package for setting the mapping.
    Next at run time  pass actual excel sheet path for ExcelFilePath property of the source to point to correct file.
    However I have set also ValidateExternalMetadata properties of the Excel Destination to false and DelayValidation properties of the package to true.
    Now my problem is the following:
    I stored the three sheets name (sheet1, sheet2, sheet3) in the Object type user variable through a script task and the foreach loop loops through the three sheets stored in the variable.
    Now, I want that at each iteration the CURRENT VALUE of the Object type user variable is mapped into another user variable wich in turn is given in input to the Excel Source.
    Resuming:
    -) I have to copy the content of three sheets (sheet1, sheet2, sheet3) of excel file into another new sheet,   sheet4.
    -) I stored the three sheets name (sheet1, sheet2, sheet3) in the Object type user variable.
    -) With a  foreach loop container I loops the three sheets stored in the Object type user variable.
    -) Within a foreach loop container I have a Data Flow Task that transfer data from source sheet (sheet1, sheet2, sheet3) into destination sheet, sheet4.
    -) PROBLEM: how to change dinamically at each iteration of the foreach loop the name of source sheet? In the destination excel Task the sheet is always the same at each iteration, sheet4. But in the source excel task the name of sheet musts change at each
    iteration. In particular at the first iteration the name of the source sheet must be "sheet1$", at the second iteration "sheet2$", in the last iteration "sheet3$".
    How to change sheet name dinamically at each iteration?
    thanks.

  • Loading data from multiple tables to multiple sheets of excel using SSIS

    I have a requirement in which I want to load data from 13 tables to 13 respective sheets of single excel file using SSIS.
    Can anyone know SSIS logic for developing package for this?

    see similar example here
    http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
    In your case you need to use loop to iterate through tables
    First get list of tables in a object variable created in SSIS using INFORMATION_SCHEMA.TABLES view
    Then add a for each loop based on ADO.NET variable enumerator to iterate through tables and inside loop follow method as in the above link to create the sheet first and populate it.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to find sheet names and number of sheets in excel file

    Hello friend
    I am reading and writing excel sheet with jdbc -odbc .
    But i am not getting excel sheets name and how many sheets in any
    excel file .
    I don't want to use third party tool such as apache or jxl .
    please give suggestion .
    Regards,
    Nitin Kumar jain

    I think you can find them via Connection.getMetaData(). There's a call in the metadata block which lists tables - tables approximately corespond to sheets in a workbook (I think there's a $ prepended to the names).

  • Formula to calculate SUM of multiple sheets of excel and the result to be stored in another excel sheet and pop up alerts for multiple rows

    I have a excel with multiple
         sheets with data as shown below
    SHEET 1
    A 1
    B 2
    C 3
    SHEET 2
    B 1
    C 2
    A 3
    SHEET 3
    C 1
    A 2
    B 3
    My
    query is splitted into 3 categories
    I want to have a formula to do math calculation such that data of "A" of SHEET 1 is  calculated with "A" of SHEET2 irrespective of the location of "A".
    When I include SHEET3, the formula should automatically identify the location of "A" or "B" or "C" and give the result corresponding to A, B or C. Since I want to bifurcate daily report and output printed. I want to use another
    excel for output. How to link multiple sheets of one excel and print the output of above in
         another excel?
    Assume, I have 4 SHEETS,  "SHEET 1", "SHEET 2", "SHEET 3" and "SHEET 4". Math calculation need to be done using all 4 sheets. If
    I include "SHEET 5", the formula should ignore SHEET 1  automatically and give the results of SHEETS 2 to 5. Similarly, if I include SHEET 6, SHEET 1 and 2 need to be ignored for further calculation and SHEET 3-6 need to be used. How to write
    such formula?
    How to get pop up alert for multiple rows, if a specific condition is hit?

    Maybe VBA Code should be a good option for you. I suggest you post you issue to
    Excel for Developers forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thanks for your understanding.
    Best Regards,
    Wind

  • How do I convert multiple sheets in excel into one pdf document?

    How do I convert multiple sheets (tabs) in excel to one combined pdf document?

    Hi Ptizer,
    If you have Acrobat PDFMaker  enable on Ms Excel. You can click on Create PDF.
    And choose settings as highlighted on screen shot it should do the job for you.
    Regards,
    Ajlan Huda.

  • Reading second sheet of excel file while uploading

    Hello Freinds,
    I want to read second sheet of an excel file while taking the data from excel file into an internal table.
    Kindly help me with a FM which would take the sheet number too with the input OR a suitable option.

    Hi ,
    Try these links:
    Type conflict while uploading data from Excel sheet to Internal table
    FM for uploading data into internal table from Excel sheet
    Or
    Try using this FM:  'TEXT_CONVERT_XLS_TO_SAP'
    Thank You.
    Regards,
    Dhanalakshmi L

  • How to download data from different sheet of excel file.

    Hi Friends,
    I have a Excel file with different sheet like sheet 1, sheet 2 and so on,
    and i have to download each sheet data in to different internal tables.
    Is there any FM or something else.
    Pl. help
    Thanks
    Sunil.

    Hi,
       You can create the function module for this.
    The code sample is as below:
    *Code Sample *
    FUNCTION Z_UPLOADING_FROM_2SHEETS.
    ""Local interface:
    *" IMPORTING
    *" VALUE(FILE_NAME) LIKE RLGRAP-FILENAME
    *" VALUE(START_ROW_SHEET1) TYPE I
    *" VALUE(START_COLUMN_SHEET1) TYPE I
    *" VALUE(START_ROW_SHEET2) TYPE I
    *" VALUE(START_COLUMN_SHEET2) TYPE I
    *" VALUE(END_ROW_SHEET1) TYPE I
    *" VALUE(END_COLUMN_SHEET1) TYPE I
    *" VALUE(END_ROW_SHEET2) TYPE I
    *" VALUE(END_COLUMN_SHEET2) TYPE I
    *" TABLES
    *" IT_DATA1 STRUCTURE ALSMEX_TABLINE
    *" IT_DATA2 STRUCTURE ALSMEX_TABLINE
    *" EXCEPTIONS
    *" INCONSISTENT_PARAMETERS
    *" UPLOAD_OLE
    DATA DECLARATION
    DATA: excel_tab TYPE ty_t_sender,
    excel_tab1 TYPE ty_t_sender.
    DATA: ld_separator TYPE c.
    DATA: application TYPE ole2_object,
    workbook TYPE ole2_object,
    SHEET TYPE OLE2_OBJECT,
    range TYPE ole2_object,
    worksheet TYPE ole2_object.
    DATA: h_cell TYPE ole2_object,
    h_cell1 TYPE ole2_object.
    DATA: ld_rc TYPE i.
    MESSAGE DEFINATION
    DEFINE m_message.
    case sy-subrc.
    when 0.
    when 1.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    when others. raise upload_ole.
    endcase.
    END-OF-DEFINITION.
    PARAMETER CHECK
    IF START_ROW_SHEET1 > END_ROW_SHEET1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF START_COLUMN_SHEET1 > END_COLUMN_SHEET1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF START_ROW_SHEET2 > END_ROW_SHEET2.
    RAISE inconsistent_parameters.
    ENDIF.
    IF START_COLUMN_SHEET2 > END_COLUMN_SHEET2.
    RAISE inconsistent_parameters.
    ENDIF.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    ld_separator = cl_abap_char_utilities=>horizontal_tab.
    OPENING EXCEL FILE
    IF application-header = space OR application-handle = -1.
    CREATE OBJECT application 'Excel.Application'.
    m_message.
    ENDIF.
    CALL METHOD OF APPLICATION 'Workbooks' = WORKBOOK.
    m_message.
    CALL METHOD OF application 'Workbooks' = workbook.
    m_message.
    CALL METHOD OF workbook 'Open' EXPORTING #1 = FILE_NAME.
    m_message.
    CALL METHOD OF APPLICATION 'Worksheets' = SHEET EXPORTING #1 = 1.
    m_message.
    CALL METHOD OF APPLICATION 'Worksheets' = SHEET EXPORTING #1 = 1.
    m_message.
    CALL METHOD OF SHEET 'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    MARKING OF WHOLE SPREADSHEET
    CALL METHOD OF sheet 'Cells' = h_cell
    EXPORTING #1 = START_ROW_SHEET1 #2 = START_COLUMN_SHEET1.
    m_message.
    CALL METHOD OF sheet 'Cells' = h_cell1
    EXPORTING #1 = END_ROW_SHEET1 #2 = END_COLUMN_SHEET1.
    m_message.
    CALL METHOD OF sheet 'RANGE' = range
    EXPORTING #1 = h_cell #2 = h_cell1.
    m_message.
    CALL METHOD OF range 'SELECT'.
    m_message.
    Copy marked area (SHEET1) into Clippboard
    CALL METHOD OF range 'COPY'.
    m_message.
    Read clipboard into ABAP
    CALL METHOD cl_gui_frontend_services=>clipboard_import
    IMPORTING
    data = excel_tab
    EXCEPTIONS
    cntl_error = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE a037(alsmex).
    ENDIF.
    PERFORM separated_to_intern_convert TABLES excel_tab IT_DATA1
    USING ld_separator.
    Clear the clipboard
    REFRESH excel_tab.
    CALL METHOD cl_gui_frontend_services=>clipboard_export
    IMPORTING
    data = excel_tab
    CHANGING
    rc = ld_rc
    EXCEPTIONS
    cntl_error = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS = 4
    Working in Second Excel Work Sheet
    CALL METHOD OF APPLICATION 'Worksheets' = SHEET EXPORTING #1 = 2.
    m_message.
    CALL METHOD OF SHEET 'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    Mark Sheet2
    CALL METHOD OF sheet 'Cells' = h_cell
    EXPORTING #1 = START_ROW_SHEET2 #2 = START_COLUMN_SHEET2.
    m_message.
    CALL METHOD OF sheet 'Cells' = h_cell1
    EXPORTING #1 = END_ROW_SHEET2 #2 = END_COLUMN_SHEET2.
    m_message.
    CALL METHOD OF sheet 'RANGE' = range
    EXPORTING #1 = h_cell #2 = h_cell1.
    m_message.
    CALL METHOD OF range 'SELECT'.
    m_message.
    Copy Marked Area (Sheet2) into Clippboard
    CALL METHOD OF range 'COPY'.
    m_message.
    Read Clipboard into ABAP
    CALL METHOD cl_gui_frontend_services=>clipboard_import
    IMPORTING
    data = excel_tab1
    EXCEPTIONS
    cntl_error = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE a037(alsmex).
    ENDIF.
    PERFORM separated_to_intern_convert TABLES excel_tab1 IT_DATA2
    USING ld_separator.
    Clear Clipboard
    REFRESH excel_tab.
    CALL METHOD cl_gui_frontend_services=>clipboard_export
    IMPORTING
    data = excel_tab1
    CHANGING
    rc = ld_rc
    EXCEPTIONS
    cntl_error = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    OTHERS = 4
    Leaving Application .
    CALL METHOD OF application 'QUIT'.
    m_message.
    FREE OBJECT application.
    m_message.
    ENDFUNCTION.

  • Multiple sheets from EXCEL

    Hi Everyone,
    My requirment is as follows to read multiple sheets from an EXCEL that contains MAcro and some Visual BAsic Components.
    I am using FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' to read a single sheet which works fine.
    But it brings in only one Active sheet at a time.
    Please help me resolve this.
      CREATE OBJECT application 'EXCEL.APPLICATION'.
      CALL METHOD OF application 'Workbooks' = workbook.
      CALL METHOD OF workbook 'Open' EXPORTING #1 = p_file.
    *call METHOD of Workbook 'Sheets' EXPORTING
    Open the first sheet in the workbook
      CALL METHOD OF workbook 'Worksheets' = sheet EXPORTING #1 = 1.
      CALL METHOD OF workbook 'ActivateSheet'
        EXPORTING
          #1 = 1.
      CALL METHOD OF sheet 'Activate'.
      CALL METHOD OF sheet 'Save'.
      FREE OBJECT application.
      SET PROPERTY OF application 'visible' = 0.
      CALL METHOD OF application 'QUIT'.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = '1'
          i_begin_row             = '1'
          i_end_col               = '60'
          i_end_row               = '32000'
        TABLES
          intern                  = it_data
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        WRITE:/ 'Upload Error ', sy-subrc.
      ENDIF.
      APPEND LINES OF it_data TO gt_data.
      BREAK-POINT.
      CREATE OBJECT application 'EXCEL.APPLICATION'.
      CALL METHOD OF application 'Workbooks' = workbook.
      CALL METHOD OF workbook 'Open' EXPORTING #1 = p_file.
    Open the second sheet in the workbook
      CALL METHOD OF workbook 'Worksheets' = sheet EXPORTING #1 = 2.
        CALL METHOD OF workbook 'ActivateSheet'
        EXPORTING
          #1 = 2.
      CALL METHOD OF sheet 'Activate'.
      CALL METHOD OF sheet 'Save'.
      SET PROPERTY OF application 'visible' = 0.
      FREE OBJECT application.
      CALL METHOD OF application 'QUIT'.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = '1'
          i_begin_row             = '1'
          i_end_col               = '60'
          i_end_row               = '32000'
        TABLES
          intern                  = it_data
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        WRITE:/ 'Upload Error ', sy-subrc.
      ENDIF.

    Hi ,
    Check the below link.
    [http://wiki.sdn.sap.com/wiki/display/Snippets/ReadmultiplesheetsofanExcelfileintoSAPthroughABAP]
    Thanks.
    Subhankar

Maybe you are looking for