How to Append an existing Excel file?

I am using the jexcel api to write to a new excel file. Each time i run my program, it creates a new Excel File by the name i give it. my code to create the excelFile is as below:-
File excelFile=new File(workDir+"\\"+fileName+".xls");
WritableWorkbook workbook = Workbook.createWorkbook(excelFile);
After this code i write some data to a worksheet in the above mentioned excel file. But my requirement is that I want to create the excel if it does not exist, and if it exists, then the data should be appended to the worksheet in the existing excel file. At present it creates a new excel file and does not append it.
How can it be done? does anyone have any suggestions as to how can i tackle this problem? please suggest something.
Ankit

There is no ready-to-run example, as you are searching for, available.
This has several reasons:
- It depends on the version of Excel. Examples for Excel 2007 might not work with Excel 2010 for instance.
- No one just wants to open Excel without doing anything with it.
The second point is something, i want to ask you:
Why do you want to open an existing Excel file at all? What is it, what you want to do after opening it?
If you have LV/C/C#/VB examples doing what you are looking for, why do you want to have it in TestStand directly, so NOT using existing code (saving time and effort) and basically re-inventing the wheel?
ActiveX is an interface for remote controlling and embedding applications with/in other applications on Windows systems. It is a PROGRAMMING interface.
So naturally, examples and tutorials exist for programming languages. Those examples are easily converted to TestStand sequences with a basic knowledge of the programming language and TestStand. Providing links for such tutorials/examples is a valid way to give support to fellow developers because we expect the fellow to have that basic knowledge. 
If that knowledge is not present, i highly recommend to fill that gap.
just my 2 cents,
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.

Similar Messages

  • Importing from XML to Excel - need to know how to append to existing Excel file

    Hello,
    I have several XML files that I will need to import into one Excel spreadsheet. I have been able to figure out how to import an XML file to an Excel file but when I import a second XML file, the contents of the second XML overwrite the Excel spreadsheet.
    I am looking for an option to append. Thanks in advance
    private void XmlToExcel(string xmlFilePath, string excelFilePath)
    object misValue = System.Reflection.Missing.Value;
    DataSet Trans_ds = new System.Data.DataSet();
    Trans_ds.ReadXml(xmlFilePath);
    Excel.Application excel = new Excel.Application();
    excel.Application.Workbooks.Add(true);
    System.Data.DataTable table = Trans_ds.Tables[0];
    Worksheet worksheet = (Worksheet)excel.ActiveSheet;
    Range excelRange = (Excel.Range)worksheet.get_Range("A" + worksheet.Rows.Count, Type.Missing);
    int lastRow = excelRange.get_End(XlDirection.xlUp).Row;
    int ColumnIndex = 0;
    int rowIndex = lastRow++;
    foreach (System.Data.DataColumn col in table.Columns)
    ColumnIndex++;
    excel.Cells[lastRow, ColumnIndex] = col.ColumnName;
    foreach (DataRow row in table.Rows)
    rowIndex++;
    ColumnIndex = 0;
    foreach (DataColumn col in table.Columns)
    ColumnIndex++;
    excel.Cells[rowIndex + 1, ColumnIndex] = row[col.ColumnName];
    worksheet.StandardWidth = 20.0;
    worksheet.SaveAs(excelFilePath, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
    excel.Quit();
    releaseObject(worksheet);
    releaseObject(excel);

    See if this helps.  I opened the old excel file and added the new rows into the existing workbook.
    private void XmlToExcel(string xmlFilePath, string excelFilePath, Boolean append)
    object misValue = System.Reflection.Missing.Value;
    DataSet Trans_ds = new System.Data.DataSet();
    Trans_ds.ReadXml(xmlFilePath);
    Excel.Application excel = new Excel.Application();
    Excel.Workbook Bk = excel.Workbooks.Add(true);
    System.Data.DataTable table = Trans_ds.Tables[0];
    Excel.Worksheet worksheet = (Excel.Worksheet)excel.Worksheets[1];
    Excel.Range excelRange = (Excel.Range)worksheet.get_Range("A" + worksheet.Rows.Count, Type.Missing);
    int lastRow = excelRange.get_End(Excel.XlDirection.xlUp).Row;
    int ColumnIndex = 0;
    int rowIndex = lastRow++;
    foreach (System.Data.DataColumn col in table.Columns)
    ColumnIndex++;
    excel.Cells[lastRow, ColumnIndex] = col.ColumnName;
    foreach (DataRow row in table.Rows)
    rowIndex++;
    ColumnIndex = 0;
    foreach (DataColumn col in table.Columns)
    ColumnIndex++;
    excel.Cells[rowIndex + 1, ColumnIndex] = row[col.ColumnName];
    worksheet.StandardWidth = 20.0;
    if (append == false)
    worksheet.SaveAs(excelFilePath, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
    else
    //open old workbook
    Excel.Workbook oldworkbook = (Excel.Workbook)excel.Workbooks._Open(
    excelFilePath,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing);
    //get first sheet in workbook
    Excel.Worksheet oldxlSht = (Excel.Worksheet)oldworkbook.Worksheets[1];
    //get column A of old worksheet to find last row in sheet
    Excel.Range xlRange = (Excel.Range)oldxlSht.get_Range(
    "A" + oldxlSht.Rows.Count, Type.Missing);
    int LastRow = xlRange.get_End(Microsoft.Office.Interop.Excel.XlDirection.xlUp).Row;
    int newrow = LastRow + 1;
    //get last row of new worksheet
    xlRange = (Excel.Range)worksheet.get_Range(
    "A" + oldxlSht.Rows.Count, Type.Missing);
    LastRow = xlRange.get_End(Microsoft.Office.Interop.Excel.XlDirection.xlUp).Row;
    // copy rows of new worksheet to old worksheet
    xlRange = (Excel.Range)worksheet.Rows["1:" + LastRow, Type.Missing];
    xlRange.Copy(oldxlSht.Rows[newrow, Type.Missing]);
    oldworkbook.Save();
    excel.Quit();
    releaseObject(oldxlSht);
    releaseObject(worksheet);
    releaseObject(excel);
    jdweng

  • Modify existing excel file (POI API)

    Hi All,
    Can anybody give me a reference to an example to update/modify an exsiting excel file in java.
    For creation of excel file I am using POI API. But not getting how to update an existing excel file
    using POI API.
    I'll be thankful for your help.
    Regards
    Naz

    Tabbasum wrote:
    Hi All,
    Can anybody give me a reference to an example to update/modify an exsiting excel file in java.
    For creation of excel file I am using POI API. But not getting how to update an existing excel file
    using POI API.
    I'll be thankful for your help.
    Regards
    NazYou do know that the poi.apache.org site has some nice examples, don't you?
    http://poi.apache.org/spreadsheet/examples.html
    Many other examples exist on the Internet; Google is your friend.
    Hope that helps, Naz.
    Regards,
    Jay-Z

  • Report Generation tool kit for MS office (Opening an existing excel file and appending to the bottom)

    I don't have any problems creating and filling an excel sheet with data. I use the New Report.vi, Easy Title.vi, and Easy Text.vi to create the file. I then save and dispose properly.
    What I don't seem to be able to do is open the exsting file and append data to the end of the sheet.
    Thanks in advance for your help.
    todd

    Hi Todd,
    You can do this by creating a new Excel report with the existing excel file path wired to the "template" input. Then use "Excel Get Last Row.vi" (located under Report Generation\Excel Specific\Excel General) to obtain the location of the last row. Then use that location to input new data into the file.
    Hope this helps,
    Dan

  • How to get data from an existing Excel file using report generation toolkit

    I'm trying to use the Excel Get Data vi from the report generation toolkit, but i can't figure out how to turn a browsable path into the right type for the VI.  I've tried using the New Report.vi, but that doesn't work unless you use a template.  It won't open an existing excel file and make it an open report to pull data from.
    Essentially, i have a bunch of excel files that have data in them and i want to use a VI to analyze the data.  So, i'm trying to pull in all the data directly from the excel file so i don't have to reproscess them all into text so i can use the more standard spreadsheet VIs.  But to even convert the excel file programtically in labview won't i still need to be able to open the excel file and get the data?
    Solved!
    Go to Solution.

    I C.
    Got it,
    the reason why I can view it using my Excel file because its in .CSV.
    I open Microsoft Excel to open .CSV file.
    But you can also open .csv file with notepad.
    So, you cannot open .xls with Read Spreadsheet File
    I learn something everyday
    Best regards,
    Krispiekream

  • How to send existing excel file through mail

    Hello Friends,
    I have to send mail with Excel File attachement. i have already exist Excel file and that file i hv to send through mail. so pl help me out for sending existing excel file .
    i.e. user pickup the exist excel file and that file would be sent to particular mail id.
    thank you,
    Marmik

    Hi marmik,
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • How to create a new excel file using Excel Destination when Destination file not exists.

    how to create a new excel file using Excel Destination when Destination file not exists.

    Just need to set an expression for excel connectionstring and set delay validation to true and it will create it on the fly.
    The expression should return the full path with dynamic filename in each case.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to export diadem channels to an existing excel file with a certain configuration

    Hello,
    I would like to export some channels from the Data Portal of Diadem  to an existing excel file. The excel file consists of many spreadsheets and each channel  should match one spreadsheet.
    I´ve tried to use EXCELExport() function but it doesn´t work.(this function is designed for something else, it generates a new excel file). I´ve tried to access to each spreadsheet and copy the information throughout a for statement but this solution needs a lot of time. If somebody has any idea, please help.   
    Solved!
    Go to Solution.

    Hi Ovidius,
    You have two options that I can think of.  You can export the data from the Data Portal to a temporary file, probably a CSV file, then load the data from file into the Excel template, OR you could stick with the Excel ActiveX approach but change to assigning a range of cells instead of individual cell values one at a time.
    There is an Excel File Export option in DIAdem, but it always creates a new Excel file, it can not be used to export to an existing Excel file.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • How to rename and access  worksheet form existing Excel file??

    Hi all,
    Is there any FM to access particular excel worksheet?? I want to <b>download data</b> <b>into a particular sheet</b> <b>of existing excel file</b>. Is there any FM for that??

    Re: Download into Excel Sheet
    regards
    Andreas

  • Open an existing Excel file created by Report Generation Toolkit

    How would I open an existing Excel file that has been created by the LabVIEW Report Generation Toolkit?
    Let me explain my application. I have made a test program to collect data on a device. Each time I run the program I want it to append a new row onto an existing data file. Since the tests I do are sometimes over a period of days, I cannot keep the program open and running continuously. So I have to open an existing file and append the new data to it. In technical terms, what I need is to get the 'report out' reference to the existing Excel data file without losing the data that is already there.

    For info on accessing Excel do a search in the examples for the word "Excel" you will get an example that shows how to open a spreadsheet and manipulate the data. This should get you started.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Aattach an existing Excel file to an email from SAP system.

    Hi,
    How can I attach an existing Excel file from SAP system (Example in 'DIR_TEMP' folder) & send a mail. Guess this requires a class with a method which picks up the file using the file path. Does CL_DOCUMENT_BCS provides this???? boz CL_DOCUMENT_BCS->ADD_DOCUMENT_AS_ATTACHMENT is for Add Existing Document as an Attachment,if so please let me know how with few lines of code??
    Thankx in advance.

    *  Local Data declarations
      DATA: ls_rec          TYPE somlreci1.
      DATA: lp_send_request    TYPE REF TO cl_bcs,
            lp_document        TYPE REF TO cl_document_bcs,
            lp_sender          TYPE REF TO if_sender_bcs,
            lp_recipient       TYPE REF TO if_recipient_bcs,
            lp_bcs_exception   TYPE REF TO cx_bcs.
      DATA: lt_text TYPE soli_tab,
            ls_text LIKE LINE OF lt_text,
            lv_flag.
      DATA: lt_tline TYPE TABLE OF tline.
      DATA lv_receiver TYPE ad_smtpadr.
    *  DATA lt_attach  TYPE soli_tab.
      DATA ls_tline TYPE tline.
      TRY.
    *   create persistent send request
          lp_send_request = cl_bcs=>create_persistent( ).
    * Get the text
          IF iv_stxt IS NOT INITIAL.
            CALL METHOD zfi_flexgl_common=>read_text
              EXPORTING
                iv_stxt   = iv_stxt
              IMPORTING
                et_tline  = lt_tline
                ev_failed = ev_failed.
            LOOP AT lt_tline INTO ls_tline.
              APPEND ls_tline-tdline TO lt_text.
            ENDLOOP.
          ENDIF.
    *  create and set document
    *     create document from internal table with text
          lp_document = cl_document_bcs=>create_document(
                          i_type    = iv_format_type   "'XLS' "HTM'
                          i_text    = lt_text
                          i_subject = iv_msg_subj ).
          IF it_attach IS NOT INITIAL.
    * Add attachment
    *        DATA:      l_size      TYPE sood-objlen,              " Size of Attachment
    *                   l_lines     TYPE i.                        " Lines count
    *        l_lines = LINES( it_attach ).
    *        l_size = l_lines * 255.
            CALL METHOD lp_document->add_attachment
              EXPORTING
                i_attachment_type    = 'RAW'
                i_attachment_subject = 'My attachment'
    *            i_attachment_size    = l_size
                i_att_content_text   = it_attach.
          ENDIF.
    *     add document to send request
          CALL METHOD lp_send_request->set_document( lp_document ).
    * Sender addess
    *l_sender = cl_sapuser_bcs=>create( sy-uname ).
    *call method l_send_request->set_sender
    *  exporting
    *    i_sender = l_sender.
    *      LOOP AT it_rec INTO ls_rec.
          lv_receiver = iv_rec.
          TRY.
              CALL METHOD cl_cam_address_bcs=>create_internet_address
                EXPORTING
                  i_address_string = lv_receiver
                RECEIVING
                  result           = lp_recipient.
            CATCH cx_address_bcs .
          ENDTRY.
          CALL METHOD lp_send_request->add_recipient
            EXPORTING
              i_recipient  = lp_recipient
              i_blind_copy = abap_true
              i_express    = abap_true.
    *      ENDLOOP.
          IF sy-subrc <> 0.
            ev_failed = abap_true.
            EXIT.
          ENDIF.
    *     ---------- send document ---------------------------------------
          CALL METHOD lp_send_request->send(
            RECEIVING
              result              = lv_flag ).
        CATCH cx_send_req_bcs.
          ev_failed = abap_true.
        CATCH cx_document_bcs.
          ev_failed = abap_true.
      ENDTRY.
      IF iv_commit = abap_true.
        COMMIT WORK.
      ENDIF.

  • Open existing excel file - OLE2INCL

    Hi experts,
    which is the method can I use to open existing excel file. I want to append my internal table data into the existing excel file.
    please help. I 'm using OLE2INCL.
    Example code would be appreciated.
    Thanks.
    Abhishek

    Hi Check the below program RSOLETT1 to start EXCEL application.
    Next to open the existing excel file use the macro
    Workbooks.Open
    you need to pass the file name to the method.
    Example :
      if application-header = space or application-handle = -1.
        create object application 'Excel.Application'.
      endif.
      call method  of application    'Workbooks' = workbook.
      call method  of workbook 'Open'    exporting #1 = filename.
    For appending to the list....
    We need to position the cursor at the end position
    Use the below method carefully and check how it bahaves in visible mode
    call method of worksheet 'Cells' = h_cell
          exporting #1 = i_begin_row #2 = i_begin_col.
      m_message.
      call method of worksheet 'Cells' = h_cell1
          exporting #1 = i_end_row #2 = i_end_col.
      m_message.
      call method  of worksheet 'RANGE' = range
                     exporting #1 = h_cell #2 = h_cell1.
      m_message.
      call method of range 'SELECT'.
    Use the clipboard cop and paste functionality to paste the internal table content at the  end.
    These are the general steps to do the requirement. I don't have any sample code.
    Thanks,
    Raj

  • How to open a specific excel file by activex & overwrite by set_cell_value.vi

    I've seen the 'Write Table and Chart to XL.llb', but how can i open an existing excel file/workbook/sheet and rewrite some of the data instead of open a new worksheet everytime? It may already shown in your examples somewhere, but since I'm new to activex/property node stuff, I can't figure it out. Your help is appretiated.
    Thanks
    Anthony

    The process is very similar. Starting with the example, open the diagram and you'll see a VI labled "Open Book" (The name of the VI is actually "Open New Workbook.vi". Right click on it and select Replace/Select a VI...
    Now navigate to \\Labview 7.0\examples\comm\excelexamples.llb and select the file "Open Specific Workbook.vi". This VI has an input for specifying a filename to open.
    Likewise, the example also calls a VI named "Open a New Worksheet.vi" replace that with "Open a Specific Worksheet.vi" (found in the same place).
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • OLE Download to existing Excel file

    Hi,
    I am using OLE functions to download data to an existing excel file but facing problem in opening the existing file.
    I am using the following code to open an existing file
      CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
      SET PROPERTY OF h_excel 'Visible' = 1.
      CALL METHOD OF h_excel 'Workbooks' = h_mapl.
      CALL METHOD OF h_mapl 'Open'
        EXPORTING
        #1 = p_file.
    When i debug   CALL METHOD OF h_mapl 'Open' is giving SY-SUBRC = 2.
    Please advice how to proceed.
    Regrads,
    Ramu N.

    Hi Ramu.
    Check this Demo program RSDEMO01.
    Check the transaction code DWDM. you will get some other examples as well.
    Thanks,
    Venkat.O

  • Send email with existing excel-file as attachment

    Is there a function to send an e-mail with an attachment which is an existing excel-file on my C:\-drive.
    I found lots of possibilities to send mail with internal tables as attachment but in my case the attachment is an existing excel-file (c:\test.xls)...
    thanx

    Hi,
    FOund these function modules
    Try this out.
    ISR_FI_SEND_EMAIL             
    ISR_FI_SEND_EMAIL_NEW_USER    
    SLS_CUST_SEND_EMAIL_TOOL      
    OR
    report y_cr17_mail.
    data method1 like sy-ucomm.
    data g_user like soudnamei1.
    data g_user_data like soudatai1.
    data g_owner like soud-usrnam.
    data g_receipients like soos1 occurs 0 with header line.
    data g_document like sood4 .
    data g_header like sood2.
    data g_folmam like sofm2.
    data g_objcnt like soli occurs 0 with header line.
    data g_objhead like soli occurs 0 with header line.
    data g_objpara  like selc occurs 0 with header line.
    data g_objparb  like soop1 occurs 0 with header line.
    data g_attachments like sood5 occurs 0 with header line.
    data g_references like soxrl occurs 0 with header line.
    data g_authority like sofa-usracc.
    data g_ref_document like sood4.
    data g_new_parent like soodk.
    data: begin of g_files occurs 10 ,
      text(4096) type c,
       end of g_files.
    data : fold_number(12) type c,
           fold_yr(2) type c,
           fold_type(3) type c.
    parameters ws_file(4096) type c default 'c:\debugger.txt'.
    Can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    call function 'SO_USER_READ_API1'
    exporting
       user                            = g_user
       PREPARE_FOR_FOLDER_ACCESS       = ' '
    importing
       user_data                       = g_user_data
    EXCEPTIONS
       USER_NOT_EXIST                  = 1
       PARAMETER_ERROR                 = 2
       X_ERROR                         = 3
       OTHERS                          = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    clear g_files.
    refresh : g_objcnt,
      g_objhead,
      g_objpara,
      g_objparb,
      g_receipients,
      g_attachments,
      g_references,
      g_files.
    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.
    g_header-objdes =  'sap-img.com testing by program'.
    g_header-file_ext = 'TXT'.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = sy-uname
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
      FOLMEM_DATA        =
      RECEIVE_DATA       =
    File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    append g_files.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
    method1 = 'SEND'.
    g_receipients-recnam = 'MK085'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    append  g_receipients.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header.
    *-- End of Program
    Thanks & Regards,
    Judith.

Maybe you are looking for

  • Approvals during trusted recon in OIM 11gr2

    Folks, I have a requirement to send create user approvals to a user during trusted reconciliation from a file . Is it feasible to achieve .? i.e we dont want to directly create users in OIM on trusted recon rather send them for approval and after suc

  • Dual User Accounts?

    Hello, My husband recently got an iPod and we share the same computer. I don't know what he did, but my Apple ID is now wiped out and I can only buy songs with the ID he just created. I even try the Password reminder, and still no recollection of my

  • Iphone 4 switches off

    my iphone 4 switches off when i insert the sim. dont know what to do??

  • PowerShell Copy library

    Dear All, Does anyone knows how to copy document library to another site using powershell? (with item level permissions, created by and modified by) I found a article but it doesn't help to copy all the metadata (with item level permissions) Best Reg

  • Change the arrangement of photos in a folder

    I have a folder in which I have placed numerous jpgs to be printed and bound as a book. In one view mode I can arrange the thumbnails in the order I need them, in another view they don't show up in the same arrangement. Please explain how to secure t