Download file in particular format

I want to download a file. The downloaded file should open in its corresponding application. A �.DOC� file should open in MS Word and �.XLS� file should open in MS Excel. What should be set in HttpRequest and/or HttpResponse objects to achieve this?
thx in advance

    String      objectName = "whatever_you_like.doc";
    response.setContentType( "application/octet-stream" );
    response.setHeader( "Content-Disposition", "attachment; filename=\"" + objectName + "\";" );
    OutputStream        out = response.getOutputStream();
    //....

Similar Messages

  • Download files in excel format

    Hi,
    Can anyone help me for downloading file in excel format? I have scheduled a job repeated everyday at a particular time, but it dumps a text file, NOT in excel format. My programme is an ALV.
    Code snippet would be verymuch helpfull.
    Thank,
    Thushara.

    Hello Thushara,
    here is a code i am giving you . It will take the data from a database , and download it into the excel format..
    You just can customize this program to download the data from an ALV ....
    Here is the sample code...
    REPORT  ZKUN_FILE4                              .
    TABLES: USR03,DD02L.
    DATA: ZX030L LIKE X030L.
    DATA BEGIN OF ZDFIES OCCURS 0.
         INCLUDE STRUCTURE DFIES.
    DATA END OF ZDFIES.
    DATA: BEGIN OF FLDITAB OCCURS 0,
          FLDNAME(11) TYPE C,
          END OF FLDITAB.
    DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.
    DATA TNAME LIKE DD02L-TABNAME.
    SELECT * FROM USR03 INTO TABLE ITABUSR03.
    TNAME = 'USR03'.
    PERFORM GETFIELEDS.
    PERFORM SHOW123.
    FORM GETFIELEDS.
         CALL FUNCTION 'GET_FIELDTAB'
          EXPORTING
              LANGU              = SY-LANGU
              ONLY               = SPACE
              TABNAME            = TNAME
              WITHTEXT           = 'X'
          IMPORTING
              HEADER             = ZX030L
          TABLES
              FIELDTAB           = ZDFIES
          EXCEPTIONS
              INTERNAL_ERROR      = 01
              NO_TEXTS_FOUND      = 02
              TABLE_HAS_NO_FIELDS = 03
              TABLE_NOT_ACTIV     = 04.
         CASE SY-SUBRC.
            WHEN 0.
              LOOP AT ZDFIES.
                   FLDITAB-FLDNAME = ZDFIES-FIELDNAME.
                   APPEND FLDITAB.
              ENDLOOP.
            WHEN OTHERS.
                 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  with  SY-SUBRC.
          ENDCASE.
    ENDFORM.
    FORM SHOW123.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
         EXPORTING
              FILE_NAME                 = 'C:\USR03.XLS'
              DATA_SHEET_NAME           = 'USER LIST'
        TABLES
             DATA_TAB                  =  ITABUSR03
             FIELDNAMES                =  FLDITAB
        EXCEPTIONS
             FILE_NOT_EXIST            = 1
             FILENAME_EXPECTED         = 2
             COMMUNICATION_ERROR       = 3
             OLE_OBJECT_METHOD_ERROR   = 4
             OLE_OBJECT_PROPERTY_ERROR = 5
             INVALID_FILENAME          = 6
             INVALID_PIVOT_FIELDS      = 7
             DOWNLOAD_PROBLEM          = 8
             OTHERS                    = 9.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    Hope this solves your problem.
    Regards,
    Kunal.
    Note : Reward points if found useful.

  • I want to write a program to download file from particular location

    I want to write a program to download file from particular location to client side in jsp.
    Need guidance...

    Hi Hello333,
    You have to use a servlet :
    public class SomeServlet extends HttpServlet {
        public void doPost(HttpServletRequest req, HttpServletResponse resp) throws
                                   ServletException, IOException {
            ServletOutputStream out = resp.getOutputStream();
            resp.setContentType("application/pdf"); // here is an example for a PDF file
            resp.setContentLength(fileLength); // length of the file
            out.write(fileBinaries); // the binaries of the file
    }

  • Issue while downloading file in .CSV format

    Hi,
    I need to download the file in .CSV format.
    I hade used FM SAP_CONVERT_TO_CSV_FORMAT  and then used GUI_Download.
    Now when I am opening file which is downloaded, it gives all the data in a single column. If there are 5 fields in my table, the generated file gives the data of all the 5 fields in a single column.
    Could you please help?

    Hi try wi th the following code.
    TYPE-POOLS : truxs.
    DATA: t_file TYPE STANDARD TABLE OF type_file.
    data:t_conv_data TYPE truxs_t_text_data.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ', '
      TABLES
        i_tab_sap_data             = t_file
    CHANGING
       i_tab_converted_data       = t_conv_data
    EXCEPTIONS
       conversion_failed          = 1
       OTHERS                     = 2.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                = 'C:\TESTCSV.CSV'
        filetype                = 'ASC'
        write_field_separator   = '  '
      TABLES
        data_tab                = t_file
       fieldnames              = names
      EXCEPTIONS
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        no_authority            = 5
        unknown_error           = 6
        header_not_allowed      = 7
        separator_not_allowed   = 8
        filesize_not_allowed    = 9
        header_too_long         = 10
        dp_error_create         = 11
        dp_error_send           = 12
        dp_error_write          = 13
        unknown_dp_error        = 14
        access_denied           = 15
        dp_out_of_memory        = 16
        disk_full               = 17
        dp_timeout              = 18
        file_not_found          = 19
        dataprovider_exception  = 20
        control_flush_error     = 21
        OTHERS                  = 22.

  • Download file in different formats(its urgent)

    Hi experts,
    I have a problem when downlaod a file in different formats.
    File should be downloaded 3 Formats.
    1. DWG
    2. DXF
    3. PDF
    this file is used for CAD Drawings.
    So i required a Functional Modules to generate a file in 3 different formats.

    Hi,
    You can download an internal table data (of report format) into PDF
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    * BIN_FILESIZE =
    filename = i_pfad
    filetype = 'BIN'
    * IMPORTING
    * FILELENGTH =
    TABLES
    data_tab = i_att_cont
    EXCEPTIONS
    file_write_error = 1
    no_batch = 2
    gui_refuse_filetransfer = 3
    invalid_type = 4
    OTHERS = 5.
    But DWG DXF are third party specific, i think in SAP we don't have functional modules to download in these
    aRs
    Points are always welcome

  • Download File In Csv Format

    Hi all,
        I want to create a file on the presentation server with csv format. i used gui_download function. The file is created but it is not csv format.
    it is urgent please can you help e out in this
    I used filetype as 'ASC' then CSV but in vain
    GV_ERR_FNAME = '
    SAM\ERRORFILE.CSV'
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                        = GV_ERR_FNAME
        FILETYPE                        = 'ASC'
        WRITE_FIELD_SEPARATOR           = 'X'
      TABLES
        DATA_TAB                        = GT_ERROR_TAX
    THANKX IN ADV

    Please check out this sample program.
    report zrich_0001.
    data: begin of itab occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          fld3(10) type c,
          end of itab.
    data: begin of iout occurs 0,
          rec(1000) type c,
          end of iout.
    parameters: p_file type localfile default 'C:test.csv'.
    data: file type string.
    start-of-selection.
    * Build the ITAB
      itab-fld1 = 'A'.
      itab-fld2 = 'B'.
      itab-fld3 = 'C'.
      append itab.
      itab-fld1 = 'D'.
      itab-fld2 = 'E'.
      itab-fld3 = 'F'.
      append itab.
      itab-fld1 = 'G'.
      itab-fld2 = 'H'.
      itab-fld3 = 'I'.
      append itab.
    * Build the output internal table from ITAB
    * Concatenate all fields into IOUT-REC
      loop at itab.
        concatenate itab-fld1 itab-fld2 itab-fld3 into iout-rec
                    separated by ','.
        condense iout-rec no-gaps.
        append iout.
      endloop.
    * Now Download
      file = p_file.
      call function 'GUI_DOWNLOAD'
           exporting
                filename = file
           tables
                data_tab = iout
           exceptions
                others   = 22.
    Regards,
    Rich Heilman

  • Downloading files in mp3 format

    I am a novice at this. I have an mp3 player, but not an ipod. Can I download files from the itunes store in mp3 format so that I can play them on my mp3 player?
    I downloaded one file from the itunes store. However, It won't work in the format that it is in. Please help. I really want to buy music but I need it in the format that i require.

    Sorry, songs downloaded from the iTunes store are available in Protected AAC format only, which means that they are only playable on your PC and iPods. Another alternative would be to burn the downloaded song to a CD and then re-rip it as an MP3. You'd lose some quality, but at least it would be playable on your player.

  • Downloading file - MS WORD FORMAT

    hi.
    I am trying to make a download on user request in MS-WORD format. I have already downloaded the file in CSV format successfully. What i want to know is how to arrange data in word file ... i.e there should be some tags, or keywords which will help me to make table in word file, bold specific font, alignment ... and such stuff.
    can you tell me how can i?

    You can try setting the content type.
    Search for the appropriate type and use it.
    - Subramanyam V

  • Download file in txt format

    Hi,
    Im using Forms 6i,
    The output data is not spliting into lines by line .in between the lines there is a small box.If i open the same file in word itis spliting line by line.
    PROCEDURE do_based_customers (p_org_id in number,p_user_id in number,p_inv_org in number,p_location in varchar2,
              p_route in varchar2, p_dodatefrom in date,p_dodateto in date, p_dofrom in number, p_doto in number) is
    l_path varchar2(100) := '/export/home/loadman';
    l_filename varchar2(20000) := 'hht_cust_'||sysdate||'.txt' ;
    l_buffer varchar2(80) := 'this is a test';
    l_outfile utl_file.file_type;
    cursor c1 is
    select * from table;
    begin
    l_outfile := utl_file.fopen(l_path, l_filename, 'w');
    for rec1 in c1
    loop
         l_filename := rec1.cust_code||'~'||rec1.cust_name||'~'||rec1.ROUTE_CODE||'~'||rec1.LOCATION_CODE;
              utl_file.put_line(l_outfile, l_filename);
    end loop;
    utl_file.fclose(l_outfile);
    exception
    when others then
    utl_file.fclose(l_outfile);
    dbms_output.put_line(sqlerrm);
    end do_based_customers;
    Thsi is the code to download the data.Itis saving in a TEXT FORMAT.
    Can any one help me in this to get reslove my problem.

    Maybe you need ot issue unix2dos -ascii oldfile newfile on the os.

  • Downloading file in xls format

    Hi All,
    I have a program that downloads data from a server to the local machine in xls format, via a JSP. The data comes from a ResultSet which I read and convert to csv format, but using ";" as the separator (it works..) and "\n" for each new line I require. I then set the response to download the file. Eveything works fine when I run the web application locally, the file downloads and opens in Excel, BUT when I do the same accessing a remote server running on Solaris, I have a problem opening the downloaded xls. Everything works fine until I try to open the file, Excel tells me that it can't read the first record.
    Here's my code:
    String path = servlet.getServletContext().getRealPath("/");
    PrintWriter printWriter = new PrintWriter(new OutputStreamWriter( new FileOutputStream( path+ "upload/excel.csv" )));
    String data;
    String fileName; // a filename set when I read the data
    // read data, put ";" and "\n" where required
    printWriter.println(data);
    printWriter.close();
    response.setContentType("application/binary");
    response.setHeader("Content-Disposition","attachment" + ";fileName=\"" + filName + ".xls" + "\"");
    RequestDispatcher rd = request.getRequestDispatcher("destination.jsp");
    rd.include(request, response);
    It works from Windows to Windows, but something's amiss when I try it from Solaris to Windows.
    Any help is greatly appreciated!!

    Most probably it has to do with line.separator system property which is different between windows and unix.
    I noticed you using a printWriter.
    The println method will use the appropriate line separator for the platform it is running on. (from the System properties)
    I would try saving the file to disk rather than opening, to see if you can discern the differences.
    Also - what does the included jsp do? does it just include the newly created file?
    Do you need that file? Could you just stream it straight out to the user?
    ie instead of sending it to a FileOutputStream, send it to the ServletOutputStream.
    Hope this helps some,
    evnafets

  • Downloaded files won't open

    Mail attachments, downloaded files from safari or chrome, or directly from gmail account won't open. I thought I'd resolve the problem by upgrading to Yosemite, but it still persists. The message I get is "file name" is damaged and can't be opened. You should move it to the Trash." It's the same message Gatekeeper will give you if it's programmed to only use apps that have been downloaded from the Apple store, but in my case it's with any downloaded file and any format (pdf, word, ppt, bmp, jpeg, etc.). I've gone through troubleshooting with Apple Support team but they seem to be clueless, too. Meanwhile I am stuck, can't get any work done!!!

    Do you have any third party security software installed?  That will most definitely be the culprit. 
    Gate Keeper will warn you when opening anything acquired from the internet that wasn't through the Mac App Store or it's identified developers.  You can change this to allow anything, but I would advise against it... because you need to know that you are opening a file that may be suspect.
    System Preferences > Security & Privacy > General.  Unlock and set it to Anywhere if you want to leave your system wide open.  The second setting it the default setting (and best setting).
    You should still be able to open a file without changing these settings by holding down the control key as you click on the file then select open.  It will prompt you again to confirm that you want to open the file.  From then on, that file will no longer be blocked.
    Again, if you installed any third party software that is designed to perform a similar function, it will likely override anything OS X is doing.  Which is why you don't want to use said software in the first place.

  • How to Save Pdf file in a particular format

    Hi Experts,
                        Can anybody tell me how to save a pdf file in a particular format,My requirement is i have a print button in webdynpro ,when ever user clicks on print ,adobe form is opened ,if user clicks on save .Form is saving with adobe form name .My requirement is it should be saved as ID NO.Date.Pdf  form lets Id is 0456 ,form should be saved as 0456.040614.pdf format, Thanks in Advance
    Regards
    Sandesh

    Hi Sandesh,
    Please provide the complete code from print & save button.
    Thanks & Regards,
    Balamurugan G

  • HT204382 MAC PRO10.6.8 just downloaded file sent  5/2010 "BoogieWoogie" (4-wmv) I could play it then, but now it says I cannot open because its not in a format that Quicktime Player understands that I have to install addit'l software to open this type of

    MAC PRO10.6.8 just downloaded file sent  5/2010 "BoogieWoogie" (1-wmv) I could play it then, but now it says I cannot open because its not in a format that Quicktime Player understands that I have to install addit'l software to open this type of file??? WHAT software and WHERE do I find it to download?
    calico6

    Free VLC player for the Mac, check out the Icecast Radio Directory also
    http://www.videolan.org/vlc/download-macosx.html
    And if it's copy protected then
    http://www.telestream.net/flip4mac/
    If anyone is running 10.8. or later, then they might have to right or control click on the installer or app to "Open" to bypass Gatekeeper controls at least once, then it learns it's a ok to be trusted program.

  • How to convert binary file to a particular format?

    Hi,
    I am having a requirement. I have in database various kinds of files stored as binary format. Its a sybase database. Now the files can be .pdf, or .doc also. But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column value which contains the file in binary format.
    But tricky part is how to convert the binary file entry in a proper respective file format? So I have another column which basically has the value to tell the type of file. So I have ".doc" or ".pdf" as each entry of file...
    So please help me how can we do this using Java?
    THanks

    Hi,
    I am having a requirement. I have in database various
    kinds of files stored as binary format. Its a sybase
    database. Now the files can be .pdf, or .doc also.
    But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column
    value which contains the file in binary format.
    But tricky part is how to convert the binary file
    entry in a proper respective file format? So I have
    another column which basically has the value to tell
    the type of file. So I have ".doc" or ".pdf" as each
    entry of file...
    So please help me how can we do this using Java?
    THanks

  • Downloading file in UTF-8 format

    Hi,
    I want to download a file in UTF-* format.
    i have written the following code to download it in UTF-8.
    OPEN DATASET L_filename FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
    LOOP AT p_struct INTO w_struct.
    TRANSFER w_struct TO l_filename.
    CLEAR w_struct.
    ENDLOOP.
    CLOSE DATASET l_filename.
    my question how do i check the file whether it is been downloaded in UTF-8 or not?
    Thanks in advance.
    neha

    Hi!
    You have to download it into your PC. For this, use an FTP program (f.e smartftp).
    Then use a text editor to check its format, for example PSPAD text editor.
    Regards
    Tamá

Maybe you are looking for

  • G62 can't find drivers for USB mouse

    For some reason I can't get my wired mouse OP-35D to work with Windows 7. When I plug it in ti the USBslot the PC can identify that its a USB mouse but can't find any drivers. I've downloded drivers from the manufacturers homepage but it's still not

  • New T5i with a video problem

    I received a new Canon T5i in the mail last week from Ritz Camera.  At first everything seemed splendid; this was an upgrade for me from an old XTi and I've been practicing with this camera so that I can cover next week's NASA launch with it.  This m

  • Using class files with applets

    I've converted a college project, a calculator, into an applet for a website resume. When the html file that loads the applet is opened on a machine with a JVM, the applet works fine. When I tested it on a machine that doesn't have a JVM, the applet

  • Web Logic Server can't start correctly

    i have problem in starting weblogic Server. It gives me "Insufficient memory for object Heap" and "Unable to initialize VM" My System Has 128 MB RAM. Can Anybody help me out from this problem. Regards Acute Minds

  • Help for Lyrics in Score problems.

    Words will not stay in alignment with notes above them, when the next word is added. If I try to correct or adjust the position the notes will then move away. If I ignore the movement I can finish up with some measures two or three times the required