Is it possible in java to send a excel file (.xls) as a parameter ???????

hey guyz iam new to java technology
please tell me whether i ca send a EXCEL file(.xls) extention as a parameter to a method (later i have to create a backup file for that excel sheet) if any one know this method please give me suggestions !!!
posting some code would be helpful
thankyou
bye n cheers
harsha

lol
If all you want is to create a backup of some file you can do:public class Foo
    public static void main(String[] args) {
        Foo f = new Foo();
        f.createBackup("something.xls");
    public void createBackup(String inFile) {
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream(inFile);
            out = new FileOutputStream(inFile + ".bak");
            int read;
            while ((read = in.read()) > -1) {
                out.write(read);
            out.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
}

Similar Messages

  • Is it possible to send an excel file through xi

    Hi all,
    is it possible to send an excel file through xi? if it is possible plz tell me that.....
    plz help me on this........
    Thanks...

    Hi,
    See this link
    integrating legacy system & sap r3 system
    Amresh

  • 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.

  • Sending an excel file as an attachment to email

    Hi,
       I am using FM 'SO_DOCUMENT_SEND_API1' to send an excel file to an email ID.But the mail is going to the SAP inbox and it is posting not to the external mail ID like ([email protected]).
    Please suggest me on this.
    Regards'
    Ved.

    Hi
      The mail sending process depends on how your company's mail server has been setup. Check the mail server setup with ur basis/network team. Moreover, go to transaction SCOT and manually trigger the mail sending process.
    In this transaction check the SMTP settings if it is set to *ALL.
    Moreover, try to manually trigger the send process in SCOT. There is a button called 'Start Send process'. After this check if the mails are still in your SAP Outbox. You can even trigger the send process from within your ABAP program by submitting the program RSCONN* (Try to search with this initials)
    Please award points if this was helpful.

  • Sending an excel file in email

    Hello all!
    I need a help, please someone helps me...
    I always send pdf by email without problems, nor i need to send an excel file by email i am using demo mail package, can anyone give an example please???
    THank you!

    I am sending by the same way of pdf but its showing the message error - ora 21560
    CREATE OR REPLACE PROCEDURE P_Envia_Nybot (V_REPORT IN VARCHAR2,V_CAMINHO_REPORT VARCHAR2) IS
    p_sender VARCHAR2(100);
    p_recipients VARCHAR2(4000);
    p_subject VARCHAR2(100) := 'Transaction Confirmation';
    p_filename VARCHAR2(5000);
    p_blob blob;
    V_NOME_ARQUIVO VARCHAR(50);
    conn utl_smtp.connection;
    i NUMBER;
    len NUMBER;
    vFlob BFILE;
    vBlob BLOB;
    v_arquivo2 VARCHAR2(500);
    v_report_novo VARCHAR2(200);
    BEGIN
    UPDATE CIMASTER SET arquivo_NYBOT = (EMPTY_BLOB())
    RETURN arquivo_NYBOT INTO vBlob;
         VFlob := BFILENAME('ORALOADNYBOT',RTRIM(v_report));
    DBMS_LOB.FILEOPEN(vFlob,DBMS_LOB.FILE_READONLY);
    DBMS_LOB.LOADFROMFILE(vBlob,vFlob,DBMS_LOB.GETLENGTH(vFlob));
    DBMS_LOB.FILECLOSE(vFlob);
         SELECT ARQUIVO_NYBOT INTO P_BLOB FROM CIMASTER;
         SELECT SENDER INTO P_SENDER FROM CIMASTER_EMAIL;
    conn := Demo_Mail.begin_mail(
    sender => p_sender,
    recipients => '[email protected]',
    subject => 'Transaction Confirmations',
    mime_type => Demo_Mail.MULTIPART_MIME_TYPE);
    Demo_Mail.begin_attachment(
    conn => conn,
    mime_type => 'TEXT/PLAIN',
    inline => TRUE,
    filename => v_REPORT,
    transfer_enc => 'base64');
    -- split the Base64 encoded attachment into multiple lines
    i := 1;
    len := DBMS_LOB.getLength(p_blob);
    WHILE (i < len) LOOP
    IF(i + Demo_Mail.MAX_BASE64_LINE_WIDTH < len)THEN
    UTL_SMTP.Write_Raw_Data (conn
    , UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, Demo_Mail.MAX_BASE64_LINE_WIDTH, i)));
    ELSE
    UTL_SMTP.Write_Raw_Data (conn
    , UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, (len - i)+1, i)));
    END IF;
    UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
    i := i + Demo_Mail.MAX_BASE64_LINE_WIDTH;
    END LOOP;
    Demo_Mail.end_attachment(conn => conn);
    Demo_Mail.attach_text(
    conn => conn,
    data => NULL,
    mime_type => 'text/html');
    Demo_Mail.end_mail( conn => conn );
    i := 1;
    len := DBMS_LOB.getLength(p_blob);
    WHILE (i < len) LOOP
    IF(i + Demo_Mail.MAX_BASE64_LINE_WIDTH < len)THEN
    UTL_SMTP.Write_Raw_Data (conn
    , UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, Demo_Mail.MAX_BASE64_LINE_WIDTH, i)));
    ELSE
    UTL_SMTP.Write_Raw_Data (conn
    , UTL_ENCODE.Base64_Encode(
    DBMS_LOB.SUBSTR(p_blob, (len - i)+1, i)));
    END IF;
    UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
    i := i + Demo_Mail.MAX_BASE64_LINE_WIDTH;
    END LOOP;
    Demo_Mail.end_attachment(conn => conn);
    Demo_Mail.attach_text(
    conn => conn,
    data => NULL,
    mime_type => 'text/html');
    Demo_Mail.end_mail( conn => conn );
    END;
    /

  • Sending an Excel file to Window user?

    How can I send an Excel file (xlsx or xls) as an attachment to an e-mail to a recipient who uses Wondows?

    Muizen wrote:
    my old portable Windows PC doesn't shown Excel as an installed program!
    So it can not open the Excel files from my iMac!
    Install the free LibreOffice (booted from the PC of course), it will open your Mac's Excel files
    How to download and install programs

  • Java imports data from Excel-File

    I try to read data from an Excel-File with a simple java program:
    Connection c = null;
    Statement stmtc = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:excelTest0");
    stmtc = c.createStatement();
    String query = "select * from [Tabelle1$];";
    ResultSet rsc = stmtc.executeQuery(query);
    ResultSetMetaData rsmdc = rsc.getMetaData();
    String temp="";
    while( rsc.next() )
    System.out.println(rsc.getString(rsmdc.getColumnName(1)));     
    rsc.close();
    catch( Exception e ) {
    everything works fine excepting the following:
    my excel-file have one row with three values
    1
    2
    3
    after i read this three values from this file, java returns
    1.0
    2.0
    3.0
    that is not what i want!!!!!!!!!!!!
    i want
    1
    2
    3
    what is the problem and how can i solve it???
    thank you for reply
    HowyC

    Follow my second method within a try block, catching NumberFormatException (or something like that...). This would not throw an exception if the value is a number. Else, it throws an exception and do nothing if the exception is thrown. For eg.,
    String resultString;
    try {
    resultString = myResultSet.getString(1);
    int i = Integer.parseInt(resultString);
    System.out.println(i);
    catch(NumberFormatException e)
    //Here, u can handle resultString as a String object.
    The same can be said of the number of rows in the excel sheet. If rs.getString(259089870) throws an exception, then it does not have a value there. Try all possible rows within a loop and u get out of the loop at the first ResultSet exception.

  • Converting java output to a excel file

    I am storing the datas retrived from a file in JTable. now i need these data to be exported to an excel file. how will i do that

    http://forum.java.sun.com/thread.jspa?threadID=600161&messageID=9526245#9526245

  • Java API for reading Excel Files.

    Hi,
    Can you please suggest me any api for reading excel files.
    Right now i am using jxl.jar for this purpose but i am searching for an open source java api better than this.
    Whether POI gives better than this ?
    Thanks,
    Amit Shah.

    Can you please suggest me any api for reading excel
    files.
    Right now i am using jxl.jar for this purpose
    but i am searching for an open source java api better
    than this.
    Whether POI gives better than this ?i don't know about jxl but poi has several features which an excel can contain and it has been vastly improved in the past few versions.

  • Using Excel 2004 on a Mac running 10.6.8 and when I try to send an Excel file no one can open, Help?

    When I try to send an Excel2004 file no one can open.  I save as Excel workbook.  I am using a Mac running 10.6.8.  I am the chair of a committee and need to save people open the attachment.  Please help  One person stated that the file came through as a dat.  What is a dat file?

    I figgered it out. The resolution of the screen was set at 600x800, so the bookmarks dropdown menu took up more space than usual. The pop out folder contents didn't have enough room to pop out. With a resolution for a slightly smaller display the drop down bookmarks menu functions perfectly.

  • Is possible to use one column in Excel file as parameter to retrieve data ?

    I'm newbie to WEB ADI
    is possible to use one column (or worksheet) in Excel file to enter data as parameters and use Web ADI to retrieve data ?
    In example - user paste in one column list of items ID's - then press a button and in another columns get data such as description, primary UOM etc.

    Hi,
    I will say no. Oracle WebADI integrators are not meant for such purpose.
    HTH,
    Nitin jain

  • JAVA code to Convert Excel file To XML file

    Hi,
    I am new to java ,Any one please share me the code to convert Excel file in to xml file.
    Thanks in advance.

    Here is a sample code for reading an Excel file. It uses JExcel API:
    package com.quicklyjava;
    import jxl.*;
    import jxl.read.biff.BiffException;
    import java.io.File;
    import java.io.IOException;
    public class JavaExcelRead {
    * @param args
    public static void main(String[] args) {
    try {
    //Create a workbook object from the file at specified location.
    //Change the path of the file as per the location on your computer.
    Workbook wrk1 = Workbook.getWorkbook(new File("C:/test.xls"));
    //Obtain the reference to the first sheet in the workbook
    Sheet sheet1 = wrk1.getSheet(0);
    //Obtain reference to the Cell using getCell(int col, int row) method of sheet
    Cell colArow1 = sheet1.getCell(0, 0);
    Cell colBrow1 = sheet1.getCell(1, 0);
    Cell colArow2 = sheet1.getCell(0, 1);
    //Read the contents of the Cell using getContents() method, which will return
    //it as a String
    String str_colArow1 = colArow1.getContents();
    String str_colBrow1 = colBrow1.getContents();
    String str_colArow2 = colArow2.getContents();
    //Display the cell contents
    System.out.println("Contents of cell Col A Row 1: \""+str_colArow1 + "\"");
    System.out.println("Contents of cell Col B Row 1: \""+str_colBrow1 + "\"");
    System.out.println("Contents of cell Col A Row 2: \""+str_colArow2 + "\"");
    } catch (BiffException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    You can further process this to convert the data extracted into XML. Hope this helps!

  • How do I send an excel file from my email adress to my Adobe account?

    I want to send a file to my Adobe account,from my email adress but I just can't do it.
    How do I go about doing this
    Newsgroup_User

    Dropbox is a popular app with which to share documents. Look for it in the App Store.

  • Is it possible to write a routine on excel file while loading data?

    Hi
    I am trying to load data from csv file(Excel flat file) into ODS, while loading data in to ODS, I need to check a condition if one Info Object in ODS is match with column C field in flat file then only the data should load, otherwise reject the data.
    any help is greatly appreciated.
    Thank you
    Harshan

    Hi Harshan,
    in your start routine:
    data: wa_ods type <name of active data ods table>,
          l_index type sy-tabix.
    loop at data_package.
    l_index = sy-tabix.
    select single * into wa_ods
    from   <name of active data ods table>
    where  <your condition>.
    if wa_ods-<fieldname> = <your condition>.
    continue.
    else.
    delete data_package index l_index.
    endif.
    endloop.
    In case of bad performance it might be necessary to post the ods-data to a internal table first and read the internal table instead of doing select single.
    Hope this helps!
    regards
    Siggi

  • Is it possible to open up an excel file inside a Web Browser not IE?

    I'm trying to find out if it is possible to open up a pivot excel file inside the a web browser, but i don't want to use Internet Explorer for that i'd prefer firefox for that.
    I have a web application that uses an excel file for one of its reports but i don't want the user to have to download the file in order to view the report and that particular report has various ordering criteria so i don't want any of the funtionality of the file to be lost in the process, so is it possible to do it? what tools would help me acomplish that?

    I don't think this is possible.
    You may be able to make it display in Firefox if the file is defined as the XML Excel format and not the xls or xlsx formats. But that would require saving the file differently and you would most likely loose all/most functionality
    You may find some Excel translators in Java (most notably POI from Apache). But they would still require you to adapt them to web format and you would have to duplicate much of the Excel functionality yourself. So it would be a long term option.
    You could check out Google Docs. They have a spreadsheet application that I believe can convert Excel files to their format. You may be able to use it inside your web site with permissions.

Maybe you are looking for

  • How to setup AI to AO

    I know this is probably possible, I just don't know how to best go about doing it. I would like to write a program to sample a waveform off of AI0 and output that same waveform on AO0 real time (or as close to real time as I can get) - with the event

  • Query of Search Results

    I need some best practices advice.  I'm not sure if there is a better way to do what I'm trying to accomplish.  The execution time is very high which is why I'm looking for alternatives.  I welcome any tips to help reduce this execution time.  Hopefu

  • Dump on table space

    HI, We are executing the TCode : FV65 and getting the dump as follows. ===== ShrtText                                                                                No storage space available for extending an internal table. What happened?           

  • Japanese Character Support

    Hi, Is IdM 8.0 able to handle Japanese characters. Not only in the input fields, but also in all menus, drop downs etc. Or does this depend on the application server setup used to host IdM? If so im using IBM Websphere 6.1, so i guess the same questi

  • Can a process update report Headings?

    Does anyone know how to use a process to directly update Report Headings, perhaps using the HTMLDB API? I need dynamic headings determined at run time, but I cannot use the PL/SQL Headings Type because I have too many columns in the report (the delim