Download "Content-Disposition" to Excel

I have a user who was having trouble getting an Excel file to download properly. When she clicked on the web link created by my procedure, her Excel file would download all the columns into one field. For myself, and most other users, it downloads normally with all the columns and fields where they should be. She was also missing the prompt asking if you wanted to open or save the file. It was just downloading to Excel right away.
Now, the user said she did not have this problem with all her Excel downloads, just this one. So I looked at the program that had the Excel download that worked for her and compared it to the one that didn't.
And there was a difference.
The download that did NOT work for her had this line of code: htp.print('Content-Disposition: inline; filename='||v_file_name1);
The download that DID work for her had this code: htp.print('Content-Disposition:attachment; filename='||v_file_name1);
In the program that wasn't working for her I replaced the part of Content-Disposition with "attachment" instead of "inline". That seemed to do it. Nothing more needs to be done, but I dont' really know why it worked. I can't seem to find a definintion of what an "inline" Content-Disposition means vs. "attachment". Anyone know? Thanks!
Oh, and here's the surrounding owa_util code in case that helps make it more clear where it was coming from:
owa_util.MIME_HEADER('text/comma-delimited', FALSE);
htp.print('Content-Disposition:attachment; filename='||v_file_name1);
owa_util.HTTP_HEADER_CLOSE;
Message was edited by:
user527082

I have a user who was having trouble getting an Excel file to download properly. When she clicked on the web link created by my procedure, her Excel file would download all the columns into one field. For myself, and most other users, it downloads normally with all the columns and fields where they should be. She was also missing the prompt asking if you wanted to open or save the file. It was just downloading to Excel right away.
Now, the user said she did not have this problem with all her Excel downloads, just this one. So I looked at the program that had the Excel download that worked for her and compared it to the one that didn't.
And there was a difference.
The download that did NOT work for her had this line of code: htp.print('Content-Disposition: inline; filename='||v_file_name1);
The download that DID work for her had this code: htp.print('Content-Disposition:attachment; filename='||v_file_name1);
In the program that wasn't working for her I replaced the part of Content-Disposition with "attachment" instead of "inline". That seemed to do it. Nothing more needs to be done, but I dont' really know why it worked. I can't seem to find a definintion of what an "inline" Content-Disposition means vs. "attachment". Anyone know? Thanks!
Oh, and here's the surrounding owa_util code in case that helps make it more clear where it was coming from:
owa_util.MIME_HEADER('text/comma-delimited', FALSE);
htp.print('Content-Disposition:attachment; filename='||v_file_name1);
owa_util.HTTP_HEADER_CLOSE;
Message was edited by:
user527082

Similar Messages

  • Content-Disposition inline/attachment

    I am using Content-Disposition for excel file download as below:
    I have searched the forum but not able to get the exact answer or solution. Please also guide me to some url if possible.
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "inline; filename=xyz.xls" );
    If I am using inline attribute but I am not able to specify the filename as xyz.xls and by default fileName provided by browser is the request URL(action-mapping in case of struts).
    But it works fine with attachment attribute and prompts for the exact file Name and works fine.
    I want to know how to specify the desired fileName with inline Attribute ? I am using the struts based request for Excel file generation.
    Best Regards,
    Amber Gupta

    if You dont't mind , I just want to tell u something on this code.
    If im wrong, Please tell me why? and what is the best way of acheiving it then,
    the code below loads whole filedata and it does not matter how big the file is. Don't you think that it will heat up the memory by doing so. and consider the method what he was doing is perfectly right. but is there any other solution/wrong with above code what MR/ms/Mrs Kenneth has written like.
    I just wanted to know the answer what is the wrong with MR. Kennth Code since i looked at it as a perfect working code(but with some glicth).
    with Regards
    Lokesh T.c
    FileInputStream in = new FileInputStream(fileToDownload);
    ServletOutputStream out = response.getOutputStream();
    int bytesRead = 0;
    byte byteArray[] = new byte[fileTODownload.length()];
    // Read in bytes through file stream, and write out through servlet stream
    /*while( ( bytesRead = in.read( byteArray ) ) != -1 ) {
    out.write( byteArray, 0, bytesRead );
    in.read(bytesArray,0,fileTODownload.length());
    out.write(bytesArray,0,fileTODownload.length());
    in.close();
    out.flush();
    out.close();

  • Facing problem with posting Excel file for download - Content in browser

    I am trying to post an Excel file to download from a servlet to a JSP. The content is written properly but to the IE browser and not in an Excel. I even tried giving the ContentType as Word/CSV etc. But nothing works, the content gets displayed only in the browser.
    PLEASE HELP.
    Code snippet in calling JSP:
    DownloadServlet downServlet = new DownloadServlet();
    downServlet.download(response);
    Code in Servlet:
    public class DownloadServlet extends HttpServlet{
    public void download(HttpServletResponse response) throws IOException {
              /*PrintWriter out = response.getWriter( );
              response.setContentType("text/html");
              out.println("<H1>Hello from a Servlet</h2>"); */
         /*HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");*/
    String strData = "This is a Test for Download";
    byte[] b = strData.getBytes();
    //response.reset();
    response.setHeader("Content-disposition", "attachment; filename=" + "Download.xls");
    response.setContentType( "application/msword" );
    //response.addHeader( "Content-Description", "Download Excel file" );
    ServletOutputStream out = response.getOutputStream();
    out.write(b);
    //out.flush();
    out.close();          
    }

    Hi Naresh,
    My thoughts on a possible solution, convert the last character value to a HEX value and check if it falls within the ASCII/Unicode CP range, Obviously this becomes easier if you are just looking at a single language character set.
    The below FM and code helps you check if the character falls within the ASCII char set.
    DATA: l_in_char TYPE string,
          l_out     TYPE xstring.
    CALL FUNCTION 'NLS_STRING_CONVERT_FROM_SYS'
      EXPORTING
        lang_used                   = sy-langu
        SOURCE                      = l_in_char
      TO_FE                       = 'MS '
    IMPORTING
       RESULT                      = l_out
      SUBSTED                     =
    EXCEPTIONS
       illegal_syst_codepage       = 1
       no_fe_codepage_found        = 2
       could_not_convert           = 3
       OTHERS                      = 4.
    IF l_out LT '0' OR l_out GT '7F'.
      WRITE: 'error'.
    ENDIF.
    Links: http://www.asciitable.com/
              http://www.utf8-chartable.de/unicode-utf8-table.pl
    Regards,
    Chen
    Edited by: Chen K V on Apr 21, 2011 11:25 AM

  • How to download content of a view into a Excel File.

    Hi All,
    Is there a way to download Content in a table maintenance screen to a local file
    Guru.

    hi
    you can download content to excel by following the below path.
    menu bar: system->list->save->locale file.
    once you click local file, a popup message with various option will be displayed, select spreadsheet and
    continue.
    the content will be downloaded to the excel file.
    regards
    mano

  • Setting the title for File download dialog when using content-disposition

    I am trying to send a file from server to client (browser). I am setting the content type of the resopnse and using the "content-disposition" header and giving the filename.
    But the issue is, when it is downloading and the dialog box is showing the progress bar, The title of the dialog box is showing something like "40% of localhost:9080.....". It doesn't show the file name in the title bar. Also, if the URL is very long (I am passing some get parameters and the servlet name is also long), I get junk characters like small boxes.
    How to set this title in the servlet?

    Is there a reason why you have to use FileReference.Save versus File.browseForSave?  In Adobe AIR, the File class, which extends the FileReference class,    provides more capabilities and has less security restrictions than the FileReference class.  Using File.browseForSave, it has a title:String parameter which is a string that is diplayed in the title bar of the dialog box.

  • Force file download? Content-Disposition?

    Hello,
    I recently started using an X-Serve with OS X 10.4.8 installed.
    This is my media server, and I'm trying to configure it to force a file download dialog when an mp3 file is pulled.
    I used to do this by using an .htaccess file with the following:
    <FilesMatch "*.mp3">
    ForceType application/octet-stream
    Header set Content-Disposition attachment
    </FilesMatch>
    But it doesn't seem to work now.
    Do I have to add a new Content Handler? If so, what do I put to force a file download?
    Thanks very much

    See Oracle Metalink,
    ..Oracle Portal Technical Forum,
    ....Subject: PORTAL - uploading files (file attachments) with file names.
    This message thread outlines javascript code that automatically captures the filename during an upload.

  • Header variable: Content Disposition for downloading file over HTTP?

    Hi All,
    I have a general content server question...Is there anyway to pass a parameter or set a setting on the content server to send the file with the header variable content-disposition set so that when a user selects a file within a browser, it doesn't open in place but asks the user whether they want to open or save the document?
    Note - I'm actually using this with ArchiveLink and displaying the link in the Portal but this forum seems the closest I can get to asking this question.
    Regards,
    Matt

    Thanks Athol.
    Although there's quite a bit of configuration options there for displaying files, there doesn't appear to be anything that let's you manipulate the HTTP header variables to set content-disposition.
    Any other ideas?
    Cheers,
    Matt
    ps. If you want to artificially see the behaviour I'm after, within IIS, you can predefine this header variable for the contentserver.dll but this makes every HTTP request act like a file that wants to be downloaded, and it calls every file contentserver.<suffix>. From a user perspective, there's nothing worse than a document opening in place in your window (losing the underlying application), or within another IE window, hence why I'd like it to act like a file download.

  • Download File by url in another server? (Content-Disposition","attachment)

    Can the file be downloaded by a url in another server?
    ie.
    Server A: JSP program
    Server B: filepath + filename = "http://xxx.com/xx/x.doc"
    e.g.
        response.setContentType("APPLICATION/OCTET-STREAM");
           response.setHeader("Content-disposition", "inline" );            
           response.setHeader("Content-Disposition","attachment; filename=\""+ fn.trim() + "\"");     
              java.io.FileInputStream fileInputStream =new java.io.FileInputStream(filepath+filename);
              int i;          
              while ((i=fileInputStream.read()) != -1) {
                      out.write(i);
              fileInputStream.close();
              out.close();     

    I tried this but it doesn't work. In the report column it shows up as Download" >_ .
    This seems to indicate that the href code is not being interpreted correctly.
    Following is exactly what I have in the URL field:
    <a href="#OWNER#.DOWNLOAD_MY_FILE?p_file=#NOTIFICATION_SEQ_ID#&v_type=SUMMARY">Download</a>Yes, I have granted execute rights to the procedure.
    Thanks,
    Dale

  • Download BSP data into Excel

    Hello all,
    I want create a BSP page, with 2 radio buttons,
    If 1st selected I want read 2 tables and display data other BSP page.
    If 2nd one selected I want download 2 tables data into excel file.
    Any one can help how to download data into excel file and display data into other bsp page.
    Thanks,
    Regards,
    Venkat

    For downloading to a spread sheet:
    Convert your fetched data to a string and convert to XSTRING format and finally download to a spread sheet.
    Sample: I selected data from vbak say vbeln and kunnr in an internal table.
    data : v_string type string, v_xstring type xstring.
    <header portion - to have the heading in the spread sheet>
    concatenate 'Order Number' 'Customer'
       cl_abap_char_utilities=>cr_lf into v_string
       separated by cl_abap_char_utilities=>horizontal_tab.
    <Line item entries from my internal table say i_vbak>
    loop at i_vbak into wa_vbak.
      concatenate v_string wa_vbak-vbeln wa_vbak-kunnr
       cl_abap_char_utilities=>cr_lf into v_string
       separated by cl_abap_char_utilities=>horizontal_tab.
    endloop.
    All the data is now in string format. Calling the FM to convert to XSTRING
      call function 'SCMS_STRING_TO_XSTRING'
        exporting
          text     = v_string
          mimetype = 'APPLICATION/MSEXCEL; charset=utf-16le' (probably create this in a variable and call here)
        importing
          buffer   = v_xstring.
    concatenate cl_abap_char_utilities=>byte_order_mark_little v_xstring into v_xstring in byte mode.
    Now we have it in XSTRING format - this can be downloaded to a spread sheet.
    v_appl = 'APPLICATION/MSEXCEL; charset=utf-16le'.
    runtime->server->response->set_header_field( name = 'content-type' value = v_appl ).
    Eliminating the cache problems when loading Excel Format
    runtime->server->response->delete_header_field( name = if_http_header_fields=>cache_control ).
    runtime->server->response->delete_header_field( name = if_http_header_fields=>expires ).
    runtime->server->response->delete_header_field( name = if_http_header_fields=>pragma ).
    Start excel in a separate window
    runtime->server->response->set_header_field( name = 'content-disposition' value = 'attachment; filename=Order_list.xls' ).
    Displaying the data in excel.
    v_len = xstrlen( v_xstring ).
    runtime->server->response->set_data( data = v_xstring length = v_len ).
    navigation->response_complete( ).
    All the above code can be written in onInputprocessing event (probably your loop/selection can be in a method of your appl class).
    I believe you are triggering the event based on a click (say radio button or a button after selecting the radiobutton).
    In the other screen you can use tableview to display your data - probably two sub screens(page fragment) to display each table.
    Regds,
    Krish

  • Bug: DocumentManager does not emit Content-Disposition header

    Good afternoon,
    I have a process with an output variable of type Document: this document has a defined filename. When invoking the process, instead of downloading the file with the defined filename, I was receiving a file with a name that looks like an MD5 hash.
    The fault for this lies with the DocumentManager application: it does not emit the content disposition header that would suggest to the browser what the real name of the octet-stream is. As such, without this header, the user agent will assume that the file-name is the endpoint name.
    The trace of the HTTP exchange is below:
    GET http://HOST:8080/rest/services/APP/SERVICE:1.0?q=83
    Cache-Control     no-cache, must-revalidate
    Date              Wed, 17 Nov 2010 12:54:29 GMT
    Pragma            no-cache
    Transfer-Encoding chunked
    Location          http://HOST:8080/DocumentManager/docm$(NUMBER)/$(HASH)?type=$(TYPE)
    X-Powered-By      Servlet/2.5 JSP/2.1
    GET http://HOST:8080/DocumentManager/docm$(NUMBER)/$(HASH)?type=$(TYPE)
    Date              Wed, 17 Nov 2010 12:54:35 GMT
    Transfer-Encoding chunked
    Content-Type      application/vnd.ms-excel
    X-Powered-By      Servlet/2.5 JSP/2.1
    The 2nd HTTP request should have included the specified header, like so:
    Content-Disposition: attachment; filename=MyExcel.xls
    RFC 2183: The Content-Disposition Header Field
    Best regards,

    Hi Robert,
    thanks for the reply. This is certainly a different aspect of the problem. The HTTP response that serves the dynamic portion (the one with the timestamp) has the response headers:
    HTTP/1.1 200 OK
    Date: Wed, 21 Jan 2015 18:05:53 GMT
    Server: Apache/2.2.29 (Unix)
    X-Powered-By: PHP/5.3.29
    Cache-Control: max-age=100000, public
    Keep-Alive: timeout=3, max=95
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: application/xml
    So it is marked as cacheable. 
    My expectation now is this:
    - when clicking the "refresh" link in the markup, there should be no new timestamp. Reason is that the dynamic part should have been cached and I would expect the XSLT engine to use the browser's caching layer when fetching fragments
    - when hitting "F5" I would expect a revalidation request to be send to the server (e.g. max-age=0 or if-modified-since). Then the server can revalidate the fragment. In my example case the fragment would be served in any case, so I would expect a
    new timestamp
    - when hitting "CTRL+F5" I would expect a request with "cache-control: no-cache" that enforces the server side caches to always return new content. I would expect a new timestamp in this case.
    What I observe is that:
    - Chrome and FF work as expected
    - IE (10/11) will always fetch the dynamic fragment, so I will even see a new timestamp when clicking the refresh link. Also the "if-none-match" header in the "F5" case is NOT forwarded to the dynamic fragment (potentially because it is
    not cached in the browser at all)
    Carsten

  • Content-Disposition not working!

    Hi!, I've a servlet which its purpose is to read a file and write it later using a ServletOutputStream. This file must not be wrote as text, but instead the idea is to write it and then browser open it with a specific application. The extension of this file is already asssociated with the program that I want to use to open it. In fact, if I use a url link to the file, the browser requests the application and all goes fine, but I want that this application runs inside the browser, so I'm using content-disposition: inline; in order to do this, but I can't make it! The browser always try to download the file. My code is this:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class imflpruebas extends HttpServlet{
         private ResultSet rs, rs2;
         private Connection connection;
         private Statement statement;
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              response.setHeader("Content-Disposition","inline");
              response.setContentType("application");
              String sFileName = "F:\\jakarta-tomcat-4.1.24\\webapps\\ImaxFileWeb\\temp\\reno_PRUEBA_0_0_0.IMX";
              File file = new File(sFileName);      
              byte[] byteContents = new byte[(int)file.length()];                
              FileInputStream in = new FileInputStream(sFileName);                
              int retcd = in.read(byteContents);                
              in.close();
              ServletOutputStream out = response.getOutputStream();
              out.write(byteContents);
              out.flush();
              out.close();
    }          I've tried to put the content type before the set header and the result is the same.
    Any ideas?
    Best whishes
    Raul          

    Hello Raul,
    There are a few things to consider. First of all, how do you want the browser to tell which application to use. Your content-type is very non-specific so the browser would never be able to tell by itself. Using a mime-type which has been mapped to an application might do a lot.
    Second, if you are using IE mime-types have little influence. IE tries to recognize the data by looking at the raw bytes and see if it recognizes the format. If not, IE will look at the URL and determine what to do with the data based on the URl extension. So if you have a link http://..../xxx.xls IE will try to show the data using Excel (if installed obviously). Adding such an extension (that can be ignored by the servlet) can do the trick with IE.
    If using IE check the Windows Explorer file settings (based on extensions). There is an "advanced" property called "confirm open before download" which should be cleared to allow an automatic open. Clearing the check "always ask before downloading" on the browser popup has no effect at all.
    Hope this helps.
    Regards,
    Silvio Bierman

  • Downloading HTML data as excel spreadsheets

    I am encountering an issue where tabular HTML data needs to be downloaded onto a user's desktop in MS Excel format.
    Basically, the download link opens the data in a new JSP, which has the response contentType set to application/vnd.ms-excel.
    However, when the pop-up asks me to save the file it saves it as a *.jsp* file.
    Could anyone please suggest why this may be happening?

    Roman-S wrote:
    Basically, the download link opens the data in a new JSP, which has the response contentType set to application/vnd.ms-excel.Terrible approach. But OK, that's another story, I am not in a mood to explain it all again. Google and you'll find.
    However, when the pop-up asks me to save the file it saves it as a *.jsp* file.You forgot the filename in the content disposition header and/or you're using Microsoft Internet Explorer.
    Could anyone please suggest why this may be happening?Add the filename to the content disposition header and/or use a decent webbrowser or append the filename as last part of the request URL path.

  • Download search result in Excel sheet

    hello Experts ,
    I am working on UCM 11g.
    We have a search template which helps us to search on UCM. I have to extract our search result in MS excel sheet. Could you please suggest the easiest way for it?
    Thanks,
    Mahesh

    Hello,
    I have been trying to create the following component from BEX's book, which creates an extra value on a drop down to export search resullts to a CSV file:
    <@dynamichtml custom_searchapi_result_options@>
    <$include super.custom_searchapi_result_options$>
    <option value="window.location='<$HttpCgiPath$>?<$QUERY_STRING
    $>&IsJava=1&MergeInclude=spreadsheet_search_results'">
    Download Spreadsheet</option>
    <@end@>
    <@dynamichtml spreadsheet_search_results@>
    Title,Author,Date,Security Group,Content ID,Content Type
    <$loop SearchResults$><$dDocTitle$>,<$dDocAuthor$>,<$dInDate
    $>,<$dSecurityGroup$>,<$dDocName$>,<$dDocType$>
    <$endloop$>
    <$setContentType("text/csv")$>
    <$setHttpHeader("Content-Disposition",
    "attachment;filename=search_results.csv")$>
    <@end@>
    As this drop down is now different in UCM 10gR3 this no longer appears to work (I get an error when adding these as a resource file) I presume I need change this include "$include super.custom_searchapi_result_options". How do I find out which include to use? I am quite new to creating custom components.
    Thanks for your help,

  • Specifying pdf document's name in browser - content-disposition problem

    Hello ,
    I want to open a PDF document in browser, which needs to have a specified filename when user tries to save it.
    My web app sends an "application/pdf" document back to the browser.
    I use the Content-Disposition HTTP header to instruct the browser to open the document inline, i.e. using the appropriate plugin, which is Adobe PDF in this case. When the user clicks Save As..., the document filename needs to be the one specified by the same HTTP header. Here is the code:
    response.setContentType("application/pdf");
    String contentDisposition = "inline; filename=\"filename.pdf\"";
    response.setHeader ("Content-Disposition", contentDisposition);
    response.setHeader ("Content-Length",new Long(file.length()).toString());Unfortunately this does not work for me. Document opens fine, but I can't get it to have the name I specified. The plugin uses the default name, which is the full URL of the document. I tried several combinations of HTTP headers, but neither worked. I tried putting an additional GET request parameter at the end of the URL, like ...&filename=filename.pdf , but that didn't work either.
    I tried Adobe 7.0 and 8.1.2.
    Any suggestions ?
    Thanks a lot!

    Thank you very much for your answer.
    Needless to say I tried opening the document in IE, FF and Chrome, and neither worked.
    I had a look at the code at your web site, and saw that you were serving files for direct download: Content-Dispositoin:attachment... .
    This works fine for me too, and the filename is recognized correctly in that case. The problem is, I want to display the PDF inline...
    My server is not configured for URL rewriting, and I would be probably quite some problem to make this app work with it, so the /filename.pdf is not an option for me.
    Edited by: matavulj on Sep 25, 2008 7:21 AM

  • How to specify the charatcer encoding for the parametes Content-Disposition

    I want to download a file with chinese name .
    response.setHeader("Content-Disposition","attachment; filename=" + fileName);
    the above part of code is working fine for english file names. but i am facing problem when i try to get file with chinese name .
    The pop up window is not defaulting with the chinese name .
    When i searched for net , in one rfc it was specified how to do that one.
    http://www.faqs.org/rfcs/rfc2184.html.
    I tried it but .. could not able to solve the problem.

    Hi,
    Am facing similar problem with russian and japanese characters in file name.
    I tried the UrlEncoder.encode(filename, "utf-8') api to encode the file name. This worked fine with IE but firefox and safari shows junk for japanese/russian characters.
    Anyone having an idea abt this?
    Thanks,
    Kapil

Maybe you are looking for

  • At a complete loss?

    Before anyone posts stuff about resetting to factory settings etc. or unplugging the modem, i have tried it all. Using a macbook pro and airport express.  Internet works great and fast when plugged directly into the modem however when trying to run w

  • 24" iMac Screens better in recent batches? One non-Apple store thinks so...

    I've been thinking about getting the Alu/Glass 24" iMac (waiting until at least Leopard's arrival) but after having read a number of threads here I thought I'd better go and check for myself... I still use a PowerBook G4 15" at home and use a second

  • HOW TO GO FOR IT MD_MRP_LIST_OVERVIEW

    Hi to All, I am new in SAP FIELD,  in one of thread i found  following  sentence *Try,function module : MD_MRP_LIST_OVERVIEW* how i will go for MD-MRP_LIST_OVERVIEW Regards kailas ugale

  • How can I get help to fix I messaging on my I pod touch

    Hi this is Kaitlyn now if I sign in to messaging will it work or not let me sign in

  • About forum - jdeveloper-adf  part

    hi admin groups, yesterday i h've been noticed strange behaviour in forum. how can i say...? yes start from here... the forums has some navigation part like previous 1 2 3 4 5 6 7 8 9 10 next when i navigate to the 10 part. and find a thread there is