Writing data on to excel sheet from java

Hi,
I have to write a java program which writes data on to Excel sheet column by column. How to do this ?

Use Jakarta's POI API: http://jakarta.apache.org/poi/index.html

Similar Messages

  • How to activate Excel sheet from java

    I need to activate excel sheet from my java program. I'm working on the project "excel tutorial". I want the user to work interactively in the excel workbook just from my java API. But i don't know how to do. please help.

    I need to activate excel sheet from my java program.
    I'm working on the project "excel tutorial". I want
    the user to work interactively in the excel workbook
    just from my java API. But i don't know how to do.
    please help.Voila :-)
    http://www.andykhan.com/jexcelapi/tutorial.html

  • How to get data to excel sheet from background

    Hello Experts,
    I have be assigned a task where i have to find out all the reports and the variants containing a ' / '. I have written the code where i am able to scan through the entire list and get a set of reports and the variantsin the internal table. NOW i have to run the code in the background and the entire set of reports and the variants in the internal table to the excel sheet . So how do I do this? I am able to get the data in the excel sheet from the foreground using the FM GUI_download. But this FM does not work in the background.
    So what should be the ideal way to do this ?
    Thanks
    Aditya

    Hi,
    You can write the file into Application server.
    OPEN DATASET dataset FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      LOOP AT it_itab INTO wa_itab.
        TRANSFER wa_itab TO dataset.
      ENDLOOP.
      CLOSE DATASET dataset
    use CG3Y transaction to download file from app server to presentation server.
    Regards
    Sree

  • Error while download the data to an Excel sheet for ECC report from EP

    Hi experts,
    I had created a report program which will download the data to an Excel sheet using SAP OLE object
    For this report i had created a tcode too. The report which i developed is perfectly working fine in SAPGUI. But if i download the data to an Excel sheet for the same report throught SAP EP.I am getting the  error that "Error in excel downlaod"
    I analyed by putting dubigg point and it throws exception while calling Function module.
    The excpetion is " OLE object id not found".
    Can any body gives a light on this why i'm not able download the excel in ep?
    Thanks,
    JB

    Hello,
    (by the way I came here to ask my question and is my first time visit but...)
    The problem is obvious: How do you expect OLE handler can "touch" the local PC Excel through a web browser? I believe that is not possible. That means (at least for me) that I have to create the whole documents before I return them to the user. That is why I use XML Office documents generation or you can try to hack some Export to excel features of ERP reports.
    Regards Otto

  • Generating Excel Sheet from Reports ......

    Hi,
    I want to generate reports both in Oracle Reports 6.0, as well
    as in Microsoft Excel. The simplest solution I thought was to
    generate the Oracle Report first and then, give a button on the
    report, which when pressed, can scan the data in the generated
    report and write it into an Excel file. The writing part to
    Excel file, I can do by using the OLE2 automation. I am not able
    to find a way to read the data in the generated report
    programatically. Is this possible and if yes, then can anyone
    suggest me a way to do this. Is there an alternate solution to
    this problem.
    regards,
    Abhilash

    Hi ,
    Modified your code .
    public void generate(IPortalComponentRequest request) throws Exception {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    HSSFRow row = sheet.createRow(3);
    HSSFCell cell = row.createCell((short)0);
    HSSFCellStyle cs1 = wb.createCellStyle();
    HSSFCellStyle cs2 = wb.createCellStyle();
    HSSFCellStyle cs3 = wb.createCellStyle();
    HSSFDataFormat df = wb.createDataFormat();
    HSSFFont f = wb.createFont();
    HSSFFont f2 = wb.createFont();
    f.setFontHeightInPoints((short) 12);
    f2.setFontHeightInPoints((short) 10);
    cs1.setFont(f);
    cs1.setDataFormat(df.getFormat("#,##0.0"));
    cs2.setFont(f2);
    cell.setCellValue(1);
    row.createCell((short)1).setCellValue(1.2);
    row.createCell((short)2).setCellValue("This is a string");
    row.createCell((short)3).setCellValue(true);
    HttpServletResponse res = request.getServletResponse(true);
    try {
    res.setContentType("application/vnd.ms-excel");
    wb.write(res.getOutputStream());
    }catch(Exception e) {}
    Check this blog for more
    Create an excel file from JAVA using HSSF api

  • Opening Excel sheet from server

    Hi I have one requirement to open Excel Sheet.
    The Excel sheet is residing in a directory parallel to WEB-INF. I am using Jboss server in Linux. in UI whenever I click on link I have to open Excel sheet from the server. Before opening Excel sheet I have to fill with some data. i am using JSP/Servlets .
    Can any one help me on this?
    Guru

    this piece of code is just open a xsl file with writing some data on the file
    it may be helpful for u .i am giving only logic.
    import java.util.*;
    import java.io.* ;
    import java.text.* ;
    public class a{
         // Main method
         public static void main (String args[])
              // Stream to write file
              //File file;
              FileWriter fout;
              String TimeStamp;
              try
              // Open an output stream
              Calendar currentdate= Calendar.getInstance();
                   int currmonth=currentdate.get(Calendar.MONTH)+1;
                   String strMonth="";
                   if(currmonth<10)
                        strMonth="0"+currmonth;
                   String wbname="Equifax"+strMonth+currentdate.get(Calendar.YEAR)+".xls";
                   System.out.println(wbname);
              BufferedWriter outfile = new BufferedWriter(new FileWriter(wbname));
                   //file=new File(filename);
                   fout = new FileWriter (wbname);
              // Print a line of text
              TimeStamp = new java.util.Date().toString();
              //String filename1=file.getName();
              outfile.write(" Apply ");
              // Close our output stream
              outfile.close();          
              // Catches any error conditions
              catch (IOException e)
                   System.err.println ("Unable to write to file");
                   System.exit(-1);
    }

  • Sending an Email by taking excel sheet from Application Server.

    Hi.
    I Searched in SDN related 'Sending an Email by taking excel sheet from Application Server'.
    But i didnt get. I got sending mails from local pc.
    Can some bdy provide me sample code how to send mail with an attachment. the attached file should get from Application Server
    Regards,
    Renu

    Hi,
    For writing data to app server from internal table:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252binput
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252boutput
    Checkout this wiki for sending XL in mail attachment:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/multiple%252battachment%252bon%252be_mail
    Thanks,
    Krishna

  • Generating EXCEL sheet from an iView

    hiii......
    i've developed a iView which holds list of users in a dropdown list box....and a button...
    now i want this data to be filled in a excel sheet when i click this button.....
    can some one send me sample code for this task...
    i have some code which doesnt work.......
    i cudnt debug this.....
    plz go through.......
    import java.io.FileOutputStream;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFCellStyle;
    import org.apache.poi.hssf.usermodel.HSSFDataFormat;
    import org.apache.poi.hssf.usermodel.HSSFFont;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    public class XLSGen {
    public void generate() throws Exception {
         HSSFWorkbook wb = new HSSFWorkbook();
         FileOutputStream fileOut = new FileOutputStream("workbook.xls");
         HSSFSheet sheet = wb.createSheet();
         HSSFRow row = sheet.createRow(3);
         HSSFCell cell = row.createCell((short)0);
         HSSFCellStyle cs1 = wb.createCellStyle();
         HSSFCellStyle cs2 = wb.createCellStyle();
         HSSFCellStyle cs3 = wb.createCellStyle();
         HSSFDataFormat df = wb.createDataFormat();
         HSSFFont f = wb.createFont();
         HSSFFont f2 = wb.createFont();
         f.setFontHeightInPoints((short) 12);
         f2.setFontHeightInPoints((short) 10);
         cs1.setFont(f);
         cs1.setDataFormat(df.getFormat("#,##0.0"));
         cs2.setFont(f2);
         cell.setCellValue(1);
         row.createCell((short)1).setCellValue(1.2);
         row.createCell((short)2).setCellValue("This is a string");
         row.createCell((short)3).setCellValue(true);
    //     HttpServletResponse res = request.getServletResponse(true);
    //     res.setContentType("application/vnd.ms-excel");
    //     wb.write(res.getOutputStream());
         wb.write(fileOut);
         fileOut.close();
    thanks and regards,
    Sudheer

    Hi ,
    Modified your code .
    public void generate(IPortalComponentRequest request) throws Exception {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    HSSFRow row = sheet.createRow(3);
    HSSFCell cell = row.createCell((short)0);
    HSSFCellStyle cs1 = wb.createCellStyle();
    HSSFCellStyle cs2 = wb.createCellStyle();
    HSSFCellStyle cs3 = wb.createCellStyle();
    HSSFDataFormat df = wb.createDataFormat();
    HSSFFont f = wb.createFont();
    HSSFFont f2 = wb.createFont();
    f.setFontHeightInPoints((short) 12);
    f2.setFontHeightInPoints((short) 10);
    cs1.setFont(f);
    cs1.setDataFormat(df.getFormat("#,##0.0"));
    cs2.setFont(f2);
    cell.setCellValue(1);
    row.createCell((short)1).setCellValue(1.2);
    row.createCell((short)2).setCellValue("This is a string");
    row.createCell((short)3).setCellValue(true);
    HttpServletResponse res = request.getServletResponse(true);
    try {
    res.setContentType("application/vnd.ms-excel");
    wb.write(res.getOutputStream());
    }catch(Exception e) {}
    Check this blog for more
    Create an excel file from JAVA using HSSF api

  • How to spool data into multiple Excel sheet if result is more then 65k rows

    Hi all,
    Wann spool data into multiple excel sheet bocz my resultant no of rows are more then 65k.
    Thanks to all in advance.....

    many choices
    1) migrate to a newer version of Excel
    2) split the files after spooling
    for instance with split
    split -l65000 file.txtor with perl, java, vb or what-so-ever
    3) do more than one report by using rownum
    spool f1
    select empno,ename  from (select rownum r,empno,ename from emp order by empno) where r<6 ;
    spool off
    spool f2
    select empno,ename  from (select * from (select rownum r,empno,ename from emp order by empno) where r<11) where r>5 ;
    spool off
    spool f3
    select empno,ename  from (select rownum r,empno,ename from emp order by empno) where r>10 ;
    spool off

  • How to append in excel sheet using Java

    Can anybody help me out in figuring out as how to append in already existing excel sheet using Java.
    I am able to to write in the existing excel sheet using HSSF but is not able to append the data row wise.
    So plz tell me how to do the same.

    Manisha_7 wrote:
    Thnx for the link......No problem.
    but i alsot wanted to know if apart from using poi there is a way to append the data in excel sheet like using JExcel.Don't know. JExcel is also not apart of Java's core API.

  • How to open and read Excel Sheet from SharePoint 2013 Document Library using C# Visual Studio 2012

    Hi,
    To achieve these are the steps that I had followed :
    1. Add the document Library path into Central Admin -> Application Mgmt -> Manage Service App -> Excel Service App -> Trusted File Locations
    2. Add Documnet Library link to Trusted Connection Proivder
    3. Open Visual Studio as Run as Administrator
    4.Create an SharePoint 2013 Empty Project.
    5.Add Service Reference : http:\\<server>\_vti_bin/excelservice.asmx
    6.Service added successfully
    7.Create a class file and add the Service Reference namespace
    There is no such class as ExcelService to call. 
    Please let me know if somebody knows how to open the Excel file into C#(2012)  either using ExcelService or any other way to open. I tried old methods of Sharepoint 2010 server but it's not able to access classes.
    Requirement is :
    Need to read the excel sheet  from Document Library and transfer all data into DataTable.
    Please help asap. 

    Hi,
    This is the forum to discuss questions and feedback for Microsoft Office, I'll move your question to the SharePoint 2013 development forum
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/home?forum=sharepointdevelopment
    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. Thank you for your understanding.
    George Zhao
    TechNet Community Support

  • Error Data Exporting to Excel sheet

    Hi Experts,
    webdynpro application , i am trying to export data to excel sheet which is coming from R3 system. it is working for 500 users but when i am trying to export more than 500 users it is showing problem.
    regards
    pavan

    Hi
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Downloading data into Excel with Format Options
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353
    Regards
    Ruturaj

  • Downloading to Excel Sheet from ALV display

    Hi Friends,
    Here i am displaying data in ALV grid. i want to download data to excel file . My data is stored in a field symbol.Could you please tell me how to download this? Currently i am trying with
    CALL FUNCTION 'OLE_SERVER_CHECK'
    CALL FUNCTION 'XXL_SIMPLE_API'
    But i am not getting the result.
    Thanks.

    Download a report to excel with format (border, color cell, etc)
    Try this program...
    Code:
    REPORT ZTEST NO STANDARD PAGE HEADING.
    this report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Regards,
    Pavan

  • Modify excel sheet from BDN/GOS and add to sales order

    Hello,
    Iu2019ve import a excel-template in OAOR (BDN) and now i want to modify the excel-sheet with my own data.
    After then I want to put it to a Sales Order (BUS2032).
    The excel sheet must indicated in the attachment list of VA02 (GOS).
    Which method I must use to copy a existing excel sheet from BDN?
    How can i modify my excel sheet from BDS and add to a existing sales order?
    Can I set the document write protected?
    Can anyone help me or have any examplesu2026
    Thanks in advance
    Edited by: Thomas Druetschel on Dec 2, 2008 3:20 PM

    Hello,
    now i can get a template from BDN and modify the excel sheet. But i want to modify the excel spreadsheet in BACKGROUND ==> have anybody a idea?
    And i need the correct method to save the modified document to BDS...
    Thanks
    i use the following code:
    TYPE-POOLS: sbdst.
    DATA go_control TYPE REF TO i_oi_container_control.
    DATA go_docking_container TYPE REF TO cl_gui_docking_container.
    DATA go_document_proxy TYPE REF TO i_oi_document_proxy.
    DATA go_excel_iface TYPE REF TO i_oi_spreadsheet.
    DATA go_error TYPE REF TO i_oi_error.
    DATA gc_exceltype TYPE soi_document_type VALUE soi_doctype_excel_sheet.
    DATA gv_retcode TYPE soi_ret_string.
    DATA gv_sheetname TYPE soi_string.
    DATA gv_inplace TYPE c.
    DATA: gv_value TYPE string.
    START-OF-SELECTION.
      PERFORM open_excel_doc_from_bds
                  USING
                      'BUS2032'
                      'BO'
                      '0010163117'
      PERFORM fill_cell
                  USING
                      'TEST123'
                      '1'
                      '2'.
    ==>> Now i want to SAVE the modified Excel Spreadshet to another Sales Order...
    *&      Form  init_excel_proxy
          text
         -->UV_INPLACE text
    FORM init_excel_proxy USING uv_inplace TYPE c.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      DATA lv_str   TYPE soi_string.
      lv_repid = sy-repid.
      lv_dynnr = sy-dynnr.
      CALL METHOD c_oi_container_control_creator=>get_container_control
        IMPORTING
          control = go_control
          error   = go_error.
      CREATE OBJECT go_docking_container
        EXPORTING
          repid     = lv_repid
          dynnr     = lv_dynnr
          side      = cl_gui_docking_container=>dock_at_bottom
          extension = 0.
    I don´t want to modify the document in the front*
      CALL METHOD go_control->init_control
        EXPORTING
          r3_application_name = ' '
          inplace_enabled     = uv_inplace
          parent              = go_docking_container
        IMPORTING
          error               = go_error.
      CALL METHOD go_control->get_document_proxy
        EXPORTING
          document_type  = gc_exceltype
        IMPORTING
          document_proxy = go_document_proxy.
    ENDFORM.                    " init_excel_iface
    *&      Form  open_excel_doc_from_bds
          text
         -->UV_CLASSNAME  text
         -->UV_CLASSTYPE  text
         -->UV_OBJECTKEY  text
         -->UV_INPLACE    text
    FORM open_excel_doc_from_bds USING uv_classname TYPE sbdst_classname
                                       uv_classtype TYPE sbdst_classtype
                                       uv_objectkey TYPE sbdst_object_key
                                       uv_inplace TYPE c.
      DATA lt_doc_uris TYPE sbdst_uri.
      DATA ls_doc_uri LIKE LINE OF lt_doc_uris.
      DATA lt_doc_signature TYPE sbdst_signature.
      DATA lv_doc_url TYPE bapiuri-uri.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      IF go_document_proxy IS INITIAL.
        PERFORM init_excel_proxy USING uv_inplace.
      ENDIF.
      CHECK NOT go_document_proxy IS INITIAL.
      CALL METHOD cl_bds_document_set=>get_with_url
        EXPORTING
          classname       = uv_classname
          classtype       = uv_classtype
          object_key      = uv_objectkey
        CHANGING
          uris            = lt_doc_uris[]
          signature       = lt_doc_signature[]
        EXCEPTIONS
          nothing_found   = 1
          error_kpro      = 2
          internal_error  = 3
          parameter_error = 4
          not_authorized  = 5
          not_allowed     = 6.
      IF sy-subrc NE 0 .
        MESSAGE 'cl_bds_document_set=>get_with_url error' TYPE 'I'.
        EXIT.
      ENDIF.
      READ TABLE lt_doc_uris INTO ls_doc_uri INDEX 1.
      lv_doc_url = ls_doc_uri-uri.
      CALL METHOD go_document_proxy->open_document
        EXPORTING
          document_url  = lv_doc_url
          open_inplace  = uv_inplace
          open_readonly = ''
        IMPORTING
          error         = go_error.
      IF NOT go_excel_iface IS INITIAL.
        FREE go_excel_iface.
      ENDIF.
      CALL METHOD go_document_proxy->get_spreadsheet_interface
        EXPORTING
          no_flush        = 'X'
        IMPORTING
          sheet_interface = go_excel_iface
          error           = go_error.
    ENDFORM.                    "open_excel_doc_from_bds
    *&      Form  fill_cell
          text
         -->UV_VALUE   text
         -->UV_COLUMN  text
         -->UV_ROW     text
    FORM fill_cell USING uv_value TYPE string
                         uv_column TYPE i
                         uv_row TYPE i.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      DATA: lt_ranges TYPE soi_range_list,
            lt_contents TYPE soi_generic_table,
            ls_contents LIKE LINE OF lt_contents[],
            lt_rangesdef TYPE soi_dimension_table,
            ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column.
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      ls_contents-row = 1.
      ls_contents-column = 1.
      ls_contents-value = uv_value.
      APPEND ls_contents TO lt_contents.
      CALL METHOD go_excel_iface->set_ranges_data
        EXPORTING
          ranges    = lt_ranges[]
          contents  = lt_contents[]
          rangesdef = lt_rangesdef[]
          no_flush  = 'X'
        IMPORTING
          error     = go_error.
    ENDFORM.                    "fill_cell
    *&      Form  get_cell
          text
         -->UV_COLUMN  text
         -->UV_ROW     text
         -->CV_VALUE   text
    FORM get_cell USING  uv_column TYPE i
                         uv_row TYPE i
                  CHANGING cv_value.
      DATA: lt_ranges TYPE soi_range_list,
          lt_contents TYPE soi_generic_table,
          ls_contents LIKE LINE OF lt_contents[],
          lt_rangesdef TYPE soi_dimension_table,
          ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column .
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      CALL METHOD go_excel_iface->get_ranges_data
        EXPORTING
          rangesdef = lt_rangesdef[]
        IMPORTING
          contents  = lt_contents[]
          error     = go_error
        CHANGING
          ranges    = lt_ranges[].
      cv_value = space.
      READ TABLE lt_contents INTO ls_contents INDEX 1.
      IF sy-subrc = 0.
        cv_value = ls_contents-value.
      ENDIF.
    ENDFORM.                    "get_cell
    *&      Form  insert_table
          text
         -->COLUMN     text
         -->ROW        text
         -->CT_DATA    text
         -->ANY        text
    FORM insert_table USING column TYPE i
                            row TYPE i
                      CHANGING ct_data TYPE table any.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      CALL METHOD go_excel_iface->insert_range_dim
        EXPORTING
          name     = 'Table'
          top      = row
          left     = column
          rows     = 1
          columns  = 1
          no_flush = 'X'
        IMPORTING
          error    = go_error.
      DATA: lt_fields_table TYPE soi_fields_table.
      CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
        TABLES
          data   = ct_data[]
          fields = lt_fields_table.
      go_excel_iface->insert_one_table(
        EXPORTING
          data_table   = ct_data[]
          fields_table = lt_fields_table[]
          rangename    = 'Table'
          no_flush     = 'X'
          wholetable   = 'X'
        IMPORTING
          error        = go_error
    ENDFORM.                    "insert_table=

  • Moving excel sheet from different files to excel template

    Hi Everyone,
    I need help from you guys.. I want to fetch excel sheet from different files (say for example from 3 excel files) and put in to one template file. If any one have idea regarding this please let me know. Thanks in advance
    Thanks & Regards
    saamy

    Hii Puneet K & nyc,
    Thanks a lot for ur links guys... am already done ...will upload the working code shortly...and am facing some other problem now...when I execute the program in LV 11.0 version its working fine, but when I try to run the same code in LV10.0 (32 bit machine) its showing this error
    "Error -2146827284 occurred at Exception occured in Microsoft Office Excel: Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook. To move or copy the data to the destination workbook, you can select the data, and then use the Copy and Paste commands to insert it into the sheets of another workbook.Help Path is C:\Program Files\Microsoft Office\Office12\1033\XLMAIN11.CHM and context 0 in copy_excel_worksheet.vi
    This error code is undefined. Undefined errors might occur for a number of reasons. For example, no one has provided a description for the code, or you might have wired a number that is not an error code to the error code input.
    Additionally, undefined error codes might occur because the error relates to a third-party object, such as the operating system or ActiveX. For these third-party errors, you might be able to obtain a description of the error by searching the Web for the error code (-2146827284) or for its hexadecimal representation (0x800A03EC)."
    If you guys know the solution please let me knoe...thanks in advance..
    Thanks & Regards
    saamy

Maybe you are looking for

  • Crystal report viewer problem

    Hi, We have CR 2008 SP2 license version and We are using visual studio 2010 and downloaded CR for visual studio 2010. After upgrading when we run the application, report displays successfully with new report viewer  but when i try to open another rep

  • Transport control program tp ended with error code 0249

    Hello guys,       I am facing an when importing transport.  After I click import to the transport in STMS, before it runs, a message window is displayed immediately. This was working find until last week, any kind of transport is followed by the same

  • What can Automator do for me?

    Can anyone give me specific examples of useful things the Automator does for you? The concept intrigues me, but I cannot figure out how it can help me.

  • If the stage size is set to 640x480 then...

    This may seem like a dumb question, but if I set the stage to 640x480, then shouldn't the testing of the flash piece be displayed at that size as well? Its almost a different size every time I test the file (ctrl+enter). What gives? Yes I have some c

  • Getting block corruption on RAC installation on vmware

    dear all i'm installing RAC on vmware (10gR2) and getting block corruption of controlfile at the end of the installation what might be the reason and how to overcome it? thanks John