Letting users download a CSV file

I need to add a link to some html code generated by a servlet that will allow users to download a csv file. The problem is that the only other link I have seen function like that was in a static html page and it simply used a href tag to identify the csv file and the user was automatically asked whether to open it or save it to their PC. When I use such a link in the servlet, the servlet displays the contents of the file in a browser window instead of giving the user the option to save it to their PC. Can someone please help me?

Are you generating the CSV file with a servlet? If so, try this:
response.setContentType("text/x-csv");
response.setHeader("Content-disposition", "inline;filename=MyOutputFile.csv");

Similar Messages

  • How to let user download multi files at the same time in WebDynpro ABAP?

    hi all:
    As you know, WeyDynpor has provided upload/download UI element, but it seems that it only support one file upload/downlaod at the same time.The following is the API method to download one file in Webdynpro:
        cl_wd_runtime_services=>attach_file_to_response(
         EXPORTING
           i_filename      = lv_filename
           i_content       = lv_content
           i_mime_type     = lv_mine_type
           i_in_new_window = abap_true
           i_inplace       = abap_false
    *      EXCEPTIONS
    *        others          = 1
    but if when use click one button, we want to provide user a html file plus 2 icons files which are used as this html file's resource file, then how to let user download these 3 files together at the same time?
    one simple way is calling the download api (cl_wd_runtime_services=>attach_file_to_response) 3 times,
    but it is very ugly that three popup windows are shown to let user select every file's download path, which is unaccepted.
    So anyone know more convienient way to handle it?
    thanks.

    Hi,
    I suggest you to zip the files and attach it to the response. Do the add file part for each of your files
         "References
         DATA lr_zip TYPE REF TO cl_abap_zip.
         "Variables
         DATA lv_zip_xstring TYPE xstring.
         DATA lv_zip_name TYPE string.
         DATA lv_file_content TYPE xstring.
         DATA lv_file_name  TYPE string.
         "Create instance
         CREATE OBJECT lr_zip.
         "Add file
         lr_zip_attachments->add(
           EXPORTING name = lv_file_name
                  content = lv_file_content ).
         lr_zip_attachments->save( RECEIVING zip = lv_zip_xstring ).
         "Attach zip file to response
         cl_wd_runtime_services=>attach_file_to_response(
           EXPORTING i_filename      = lv_zip_name
                     i_mime_type     = 'ZIP/APPLICATION'
                     i_content       = lv_zip_xstring ).

  • Downloading a .csv file as excel sheet

    hi,
    does anyone know how to ensure that when downloading a csv file, it will be opened with excel only. The browser is downloading it as a text file and not excel. how can this be prevented.
    please let me know if you have any ideas since i've been pondering over it for far too long and need help...
    thanks
    jeena

    Yes, you need to set the content type to "application/vnd.ms-excel". Of course there is no guarantee that your clients will interpret that to mean "Open with Excel", or that they will even have Excel installed on their system, but there's not much you can do about that.

  • Download to csv file

    Hi,
    Working with Download to csv file feature I realized that for one of my reports that contains an icon (with a link) in one of the columns, is not getting any value for this column in the csv file.
    This behaviour is logical due to the fact that we have an image, not a string.
    But, is there a way I can edit or force the Download to assign a string value for every icon I have in my report, so when I click in Download, the icon will be represented as a string in the new csv file?
    Thanks
    Ivo

    i'd bet the easiest way to approach this would be to select both your icon and your "string value" columns out of the database and to then use column conditions to determine which columns should be rendered in which output format. so say you had a report that just showed images in one col and a description in the next. i'd write your report to select something like...
    select '<img src="'||m.image_path||'">' my_image, m.image_name name, m.image_description
    from my_image_table m
    ...and then i'd a put condition of type "PL/SQL Expression" like...
    not htmldb_application.g_excel_format
    ...on your my_image column. i'd also put a "PL/SQL Expression" condition on your Name column like...
    htmldb_application.g_excel_format
    ...we talked about this a bit in...
    Excel Report
    ...but basically htmldb_application.g_excel_format is just a function that returns a boolean telling you whether or not the HTML DB engine is in the mode of show your page in csv format. anyhow, give it a shot and let us know if you need further assistance.
    regards,
    raj

  • How to get fixed field length when download a CSV  file ?

    hi all ,
        I had downloaded a CSV file from an ALV list which created by myself. the current layout of the CSV file is :
    aaa;bbbbbbbbbb;cc;                
                                                         for example . but what i want is :
    aaa         ;bbbbbbbbbbb            ;cc     ; 
    it means these three fields are all with fixed length don't ommitting spaces when you preview the CSV file. how should i do this ?
    best regards
    Kevin

    i got the solution.

  • When downloading a .csv file in Safari, it adds .xls, making the file filename.cvs.xls

    When downloading a .csv file in Safari, it adds .xls, making the file filename.cvs.xls
    If I rename the file, it opens just fine, if I don't it opens all in one column.
    I had found a fix on my old macbook, but just got a new MBP and it's happening again.
    Can't remember or find where the fix is.
    Thanks!

    Safari: Downloaded file's filename may have an additional extension
    http://support.apple.com/kb/TA24293
    That's from June 11, 2007!
    Working from my defective memory, this happened to me, but stopped if I unchecked 'Open safe files after downloading' in Safari Preferences/General.
    At least I think that's how I stopped it - it hasn't happened since!

  • How to approach for downloading a CSV file?

    I'm running the following query and  QoQ . Could you tell me how should I proceed for the "Download  CSV" file option?
        <!--- QoQ for FIRSTCONN --->
        <cfquery datasource = "XX.XX.X.XX" name="master1">
             SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as FIRSTCONN
                    , COUNT(Timedetail) as FIRSTOccurances
                    , EVENTS
             FROM  MyDatabase
             WHERE EVENTS = "FIRST"
             GROUP BY FIRSTCONN ;
        </cfquery>
        <!--- Detail Query --->
        <cfquery dbtype="query" name="detail1">
            SELECT  *
            FROM master1
            WHERE FIRSTCONN  >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
            AND   FIRSTCONN  <  <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
        </cfquery> 
        <!--- QoQ for SECONDCONN --->
        <cfquery datasource = "XX.XX.X.XX" name="master2">
            SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as SECONDCONN
                   , COUNT(Timedetail) as SECONDOccurances
                   , EVENTS
            FROM  MyDatabase
            WHERE EVENTS = "SECOND"
            GROUP BY SECONDCONN ;
        </cfquery>
        <cfquery dbtype="query" name="detail2">
            SELECT  *
            FROM   master2
            WHERE  SECONDCONN  >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
            AND    SECONDCONN  <  <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
        </cfquery> 
        <cfchart format="flash"  chartwidth="1000" chartheight="500" scalefrom="0" scaleto="50000" xAxisTitle="Dates" yaxistitle="Number of Connections">
             <cfchartseries  query="detail1" type="line" itemColumn="FIRSTCONN" valueColumn="FIRSTOccurances" >
             <cfchartseries  query="detail2" type="line" itemColumn="SECONDCONN" valueColumn="SECONDOccurances" >
             </cfchartseries>
        </cfchart>
    The cfform code I'm using is as follows:
    <cfform format="flash" preloader ="false">
    <cfformgroup type="horizontal">
      <cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#form.startdate#">
      <cfinput type="dateField" name="enddate" label="End Date" width="100" value="#form.enddate#">
      <cfinput name="submitApply" type="submit" value = "Apply">
      <cfinput name="cancel" type="submit" value="Download CSV">
    </cfformgroup>
    Desired Output:
    I have attached the image for the output below. Please find it attached.
    Basically, if a date range is 21June to 21 July. The output must be as shown in the image. (I have omitted THIRDCONN etc for the sake of simplicity in my code).
    Please let me know how should I go about this problem and let me know if I can answer more questions.

    It's not built into the language. Your best bet is probably to put the CSV-Reading logic into its own class.
    Or find one of the thousands of classes that already implement such a thing.

  • Exchange PowerShell script to get mailbox properties of user from a CSV file

    Hi Team,
    I've a CSV file with alias of numerous users and I want to get their mailbox sizes and other properties. These users are dispersed in various databases of same Exchange organization.
    Need a Powershell Script, Any help?
    Muhammad Nadeem Ahmed Sr System Support Engineer Premier Systems (Pvt) Ltd T. +9221-2429051 Ext-226 F. +9221-2428777 M. +92300-8262627 Web. www.premier.com.pk

    You can use this and modify it to what you need. Output to a file (IE: Export-CSV "path to file"
    If you need more specifics let me know. This one is for one user at a time but can be used to read a CSV file.
    # Notifies the user a remote session needs to be started
    Write-Host "Get a users mailbox size" -fore yellow -back red;
    Write-Host "Please wait while a remote session started" -fore red -back yellow;
    # Import a remote session with exchange
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchangeservername/Powershell/ -Authentication Kerberos
    Import-PSSession $Session
    Do {
    # Prompts user for a name
    $name = Read-Host "Enter a username"
    # Get the mailbox statistics for that user
    Get-MailboxStatistics $name | fl totalitemsize, storagelimitstatus, totaldeleteditemsize | out-default
    # Give the user a choice to test another or EXIT
    $Output = Read-Host "Press Y to continue or ENTER to exit"
    # Ends the program if the user does not press Y
    Until ($Output -ne "Y")
    HossFly, Exchange Administrator

  • How to download a CSV file in AL11 to XL into diferent tabs  ?

    Hello All,
            I have a file in AL11 of type CSV.
    When I download this file into XLS from AL11 all the data is downloaded under one tab itself.
    But I want the data in separate columns wherever there is a comma in the line.
    How can I do this ?
    Regards,
    Deepu.K
    null

    Hello manoj,
           Thanks for ur reply.
    But I forgot to mention that I want this functionality when I directly download from AL11..not thru the Program.
    i.e my job is to place the files in the AL11.
    The end users will check the file name across the appropriate folder and then use the Download option in the AL11 Transaction to download it.
    Now when they see the file in AL11 it is with comma separated.
    When they download it ..it's still comma separated and in only one tab.
    I want to avoid this ..
    Is it possible ?
    Regards,
    Deepu.K

  • Download to CSV file using FLEX

    Hi,
    I have download to CSV working fine, but i need the filename along with extension "CSV" when filereference object opens in browser,
    though i included CSV in the filename flex is ignoring it..
    Can anybody let me know how i can accomplish what i am looking for ?
    Thank You...Anu
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import sample.DataGridDataExporter;
    import flash.net.FileReference;
    import flash.net.URLRequest;
    import flash.net.URLVariables;
    import flash.net.URLRequestMethod;
    import mx.controls.Alert;
    private static const CSV_DOWNLOAD_END_POINT:String = "http://q0571478:9081/CsvFile/servlet/GetCSV";
    private var downloadFileRef:FileReference = null;
    private function exportCSV ():void
    var csvData:String = DataGridDataExporter.exportCSV (dg);
    console.text = csvData;
    if (csvData.length > 0)
    downloadCSV (csvData);
    private function downloadCSV (csvData:String):void
    if (!downloadFileRef)
    downloadFileRef = new FileReference();
    var request:URLRequest = new URLRequest();
    var fileName:String;
    fileName = "ccdownload.csv";
    request.url = CSV_DOWNLOAD_END_POINT;
    request.method = URLRequestMethod.POST;
    request.data = new URLVariables ("csvdata=" + csvData);
    downloadFileRef.download(request, fileName);
    ]]>
    </mx:Script>
    <mx:XMLList id="employees">
    <employee>
    <name>Christina Coenraets</name>
    <phone>555-219-2270</phone>
    <email>[email protected]</email>
    <active>true</active>
    </employee>
    <employee>
    <name>Joanne Wall</name>
    <phone>555-219-2012</phone>
    <email>[email protected]</email>
    <active>true</active>
    </employee>
    <employee>
    <name>Maurice Smith</name>
    <phone>555-219-2012</phone>
    <email>[email protected]</email>
    <active>false</active>
    </employee>
    <employee>
    <name>Mary Jones</name>
    <phone>555-219-2000</phone>
    <email>[email protected]</email>
    <active>true</active>
    </employee>
    </mx:XMLList>
    <mx:Panel title="DataGrid Control Example" height="100%" width="100%"
    paddingTop="10" paddingLeft="10" paddingRight="10">
    <mx:Label width="100%" color="blue"
    text="Select a row in the DataGrid control."/>
    <mx:AdvancedDataGrid id="dg" width="100%" height="100%" rowCount="5" dataProvider="{employees}">
    <mx:groupedColumns>
      <mx:AdvancedDataGridColumn dataField="name" headerText="Name"/>
      <mx:AdvancedDataGridColumn dataField="phone" headerText="Phone"/>
      <mx:AdvancedDataGridColumn dataField="email" headerText="Email"/>
    </mx:groupedColumns>
    </mx:AdvancedDataGrid>
    <mx:Button label="Export CSV" click="exportCSV ()"/>
    <mx:TextArea id="console" width="100%" height="100%" />
    </mx:Panel>
    </mx:Application>

    this opensource component has a good sample about copying datagrid data, is not CSV but is Excel compatible (it should be easy to change to CSV)...
    http://flexed.wordpress.com/2007/08/15/customgrid-v12/
    if you need help uploading the file to the server you could take a look in the Flex Documentation for fileupload or FileReference and you should get some examples
    HTH
    Gus

  • I am try to download a CSV file and have it directly open in excel. It only opens in new page and not in excel. how do I get it to do that.

    In internet explorer I use to be able to click on a download link to have a csv file open in excel. I have never been able to open this download file before with Firefox. It turns out that I can no longer do it with Explorer either. I have sent this same question to them for help as I require this information. It is being downloaded from a secure site and is used for registration information.
    I need help as soon as possible.
    Thank you
    Rob

    See:
    *Firefox/Tools > Options > Advanced > General : Accessibility : [ ] "Warn me when web sites try to redirect or reload the page"
    The setting in "Tools > Options > Advanced > General" is meant as an accessibility feature, as you can see by the label of that section, so that people with disabilities or people who use screen readers do not get confused and is not meant as a safety protection to stop redirecting.
    See also:
    *https://support.mozilla.com/kb/Options+window+-+Advanced+panel#General_tab
    *http://kb.mozillazine.org/accessibility.blockautorefresh
    *http://kb.mozillazine.org/Accessibility_features_of_Firefox

  • How to download a CSV file to a shared network folder ?

    Hi Experts,
    I have created a report which exports a CSV file on application server using scheduled background job. I have used the OPEN DATASET feature to download the file on a location on the application server which is working fine.
    But my requirement is that I have to download this file to a shared folder which is situated on another location and is shared in my application server as 'N' drive. But when I give the path of this N drive in my report, its giving runtime error that the <filename> is not open.
    So pls help me how to give path to such shared network folder to download the file?
    Thanks,
    Vishal .

    Hi Guys,
    I tried alot but it didnt work.
    SO I decided to export the file on the application server only.
    I created a background job that runs periodically and exports the file to C drive of the application server.
    The job run sucessfully only the first time but gets cancelled after that.
    I ran the job for an hour but not a single time it finished successfully. Every time it was cancel with dump error shown below.
    +++++++++++++++++++++++++++++++++++++++++++
    Category               ABAP Programming Error
    Runtime Errors         DATASET_NOT_OPEN
    Except.                CX_SY_FILE_OPEN_MODE
    ABAP Program           ZBATCHSTOCK
    Application Component  Not Assigned
    Date and Time          01.08.2014 18:52:13
    Short text
         File "C:\GOOGLE_SAP\BATCH_DETAILS.CSV" is not open.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "ZBATCHSTOCK" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    And the same background job runs properly on development server without any cancelled job.
    So pls help me what should be the problem ??
    Thanks,
    Vishal

  • How to import users from a CSV file to UCM

    Hi All,
    is there any way to import all the users from CSV file file to oracle ucm?
    Thanks
    Hari

    There are a number of csv to ldif options out there. If you want to drop your users into WLS, then formatting into an ldif is the easiest way to bulk load.
    http://tinyurl.com/88mwxb3
    -ryan

  • How to use auto fit selection when downloading to csv file

    hi,
    I am working on reports, i need to download to a .csv file. I am using GUI_DOWNLOAD is there any option for it where text fits exactly in a single cell.
    For Eg:
    I excel there is an option (Format-column-Autofitselection).
    Then the column size increases or decreased according to the text size.

    Dear Josephine,
       There is no option the way you want of autofit. Rather while opening the CSV in excel u can do the required formatting.
    Regards,
    Deva.

  • Query - Download as CSV file

    Hi,
    By using Query (SQ01), we are able to download data in Excel format, Text format, etc. But... is there an option that I can download in CSV format.
    Thanks.....
    Rgds,
    Kian

    Hi Kian,
    you could save the Excel file in CSV format, couldn't you?
    Regards
    Bernd

Maybe you are looking for

  • How do i create an output file

    i have a 30 page invoice. i only need to email certain pages to someone. is it possible to print a page range to file and email someone that file? any help would be much appreciated

  • HT1657 Std Def. on New Apple TV

    Can I rent movies in std. def. on new apple tv ?

  • Going back to a completed question

    Hi, I have a Captivate 8 project where there are several sections with review questions at the end of each section. I am using the table of contents to allow users to move around the whole project, and have enabled the move backwards option on the qu

  • Filtering data to be shown at query level

    I am still on BW 3.0. I am developing queries for a cube. Is there a way to restrict characteristics (rows shown for a characteristics) by looking at a master data?  For example, my characteristics are showing orders, but I have a table which contain

  • My WDMyCloud Public Folder Hacked

    I just found about 30 movies uploaded to my WDMyCloud Public folder. Apparently, a hacker was using it as some sort of torrent upload/download site. I use a high end LinkSys router with all the security implemented, ie, firewall, https, dmz turned of