Setting filename sending output to Excel form servlet

Hi All
I am successfully sending my tab separated output to Excel from the servlet using the following:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","inline;filename=statistics.txt");
The output is automatically opened in a new window using excel.
However the sheet in excel is named based on the url of the servlet it came from, not statistics as i have specified. The main issue with this, apart from the niceness of it, is that if the user then generates another excel output from the same servlet then the new file is not loaded as excel already has a file by that name open and can't handle duplicate names.
I have seen many references to this syntax, but it doesn't quite work for me.
I hope someone can clarify what i am missing here.
Thanks in advance.

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
* @author Ravi Desu (rdesu)
* @version 1.0
* $Id: ExcelGen.java, Jun 1, 2004 4:43:13 PM rdesu Exp $
public class ExcelGen extends HttpServlet {
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Worksheet 1");
HSSFRow row = sheet.createRow((short) 0);
HSSFCell cell = row.createCell((short) 0);
cell.setCellValue("This is text in a cell");
httpServletResponse.setContentType("application/vnd.ms-excel");
workbook.write(httpServletResponse.getOutputStream());
In your web.xml:
<servlet>
<servlet-name>ExcelGenSrvlt</servlet-name>
<servlet-class>ExcelGen</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ExcelGenSrvlt</servlet-name>
<url-pattern>/ExcelGen.xls</url-pattern>
</servlet-mapping>
download the org.apache.poi jars from
http://www.apache.org/dyn/closer.cgi/jakarta/poi/
http://jakarta.apache.org/poi/

Similar Messages

  • Reports output in Excel form fail - Finished successf output is voided

    Hi
    We have oracle 10g application server on solaris. A few of the reports are configured to have the output in PDF and other reports in excel form.
    The reports which are configured to give the output in excel form fail with Finished successfully but output is voided.
    I have the below paramters configured
    <property name="cacheSize" value="1024"/>
    <property name="cacheDir" value="/reports/reportoutput"/>
    Are there any other parameters I should set or look out for. So that the reports are which give excel output are successfull.
    Thanks

    The problem has been solved. The report is successfull. But the OEM status was showing the message like that.
    Thanks

  • How to get the output in EXCEL form from RIDC.

    Hi,
    I want the list of all views from UCM in EXCEL form. In RIDC code i am using GET_SCHEMA_VIEWS service to get
    all the defined schema views.
    But i want this list in EXCEL sheet. How can i do this in RIDC code?
    Thanks,
    SSJ

    But i want this list in EXCEL sheet. How can i do this in RIDC code?You can't. RIDC will help you to get data from UCM to Java (in a form of an object in memory). If you want to store this object persistently as a file (e.g. in Excel spreadsheet format) you have to use other Java techniques/libraries like this one: http://www.vogella.com/articles/JavaExcel/article.html or http://jexcelapi.sourceforge.net/

  • Host a custom form on E-Business Suite Forms Servlet

    Hi.
    Is it possible to host my own form using the Forms engine integrated with E-Business Suite?. is this a good idea? or do i have to setup another forms servlet?
    I'm trying it with one form with a menu. I just Copied the mmx files and fmx files where all the fmx files of EBS suite reside. or do i need to recompile it inside linux forms compiler (adadmin) using .pll plx, fmb files?
    I manually type the url "domainname.com:8000/dev60cgi/f60cgi?formname.mmx?user=username?password=password"
    where user, password = database user (not apps user)
    when i did this, it still launched the applet but still goes to the main form of EBS? and the custom form doesn't get called..
    regards,
    anton

    I think you can do it.
    Should look in appsweb.cfg configuration file. usaually in $COMMON_TOP/html/bin
    ; 1) Runform Arguments
    ; The module argument defines the first form to be started.
    ; It is composed from parameters %prodTop%/forms/%lang%/%formName%
    ; The default looks like $APPL_TOP/fnd/<version>/forms/US/FNDSCSGN
    ; Following parameters and prodTop are used for composing module.
    ; Note: Personal Home Page modifies the lang setting automatically.
    formName=FNDSCSGN
    lang=US
    Forms servlet is just a mechanism to start the f60webmx processes on the application server (which also has the Forms listener servlet). So you will not need a seperate servlet in your case.
    HTH
    Bansi

  • Setting up FileName for Output file in SendPort

    Hi - I have a requirement setting up FileName in output file. For instance say, whatever I receive in the 'FathersName' field that Output File should be with that File Name.
    For e.g. if data received in FathersName field is JOHN, output file name should be JOHN.xml
    I am using File Adapters on Receive and send side.
    Can this be achieved just by Messaging Scenario or do I need to implement this using Orchestration ?
    If so, please advise on how to do this ?
    e.
    MBH

    To achieve this, you will have to set your filename value on one of the Context Properties available as a File Adapter macro. For example FILE.ReceivedFileName is mapped to the %SourceFileName% macro.
    You have several options to do this:
    Set FILE.ReceivedFileName in an Orchestration.  It does not have to be Promoted.
    Write the Property ReceivedFileName in namespace
    http://schemas.microsoft.com/BizTalk/2003/file-properties in a Custom Pipeline Component.
    If FathersName can be used in the file name unmodified, you set FathersName as a Promoted Property on the schema and Promote directly to FILE.ReceivedFileName.
    For 1 & 2, you will have to extract FathersName somehow, such as a distinguished field.
    A Custom Pipeline Component or direct Promotion are the only way to achieve this in Messaging only.

  • Urgent :- Sending output to SAP User's inbox as Excel Attachment.

    Hi,
    This is urgent requirement
    Requirement Description in breif :-
    1.I have a report and but when run in background, it should create an excel file and should be sent as attachment to sap inbox of the same user who is executing the report.
    2.I have tried all most all function modules. the limitations were some of the F.M are not supported in background mode (which the sap it self uses) And I could able to send data  to excel excel file only upto 255 chars per record. i.e these F.M's are allowing me to send a internal table but every record of 255 chars only.
    3.Which is not sufficient to send my ITAB contents. and contents after 255 are truncating.
    Sending output of report in Excel Format ,in Background

    Hi srinivas,
    check this thread
    Convert output display to Excel file and Email to a set of users
    Regards,
    Raj

  • Sending report output to Excel

    Dear buddies
    I'm using OLE Object in my report to send its output to excel. I find this way from an example at the same forum. But I feel that this example is for very small sized reports which have to send a few cells to excel because in this method we've to map each boiler plate and data field to excel like this.
    function B_DEPTNOFormatTrigger return boolean is
    begin
    RPT2XLS.put_cell(1, 'DEPTNO', FontColor => 10, FontSize => 8, FontStyle => RPT2XLS.BOLD);
    RPT2XLS.new_line;
    return (TRUE);
    end;
    In this way its very hard to map large reports to excel which have more than 50 or 60 data fields and labels. So is there any short way to send its output to excel. Be careful that I also dont wanna use Delimited option coz Delimited file has also to be formatted while importing to Excel. Is there anyway that OLE Object should automatically detect all my Report Labels and fields or some other solution in yours minds???

    If you are using 10g reports you can use the latest parameter desformat=spreadsheet
    Rajesh Alex

  • To send output of report to the mails ids as an excel attachment

    Hi all,
    I have a requirement that I have created a report using classes. Now I have to send output of my report to the particular mailids as an excel attachment.
    Can anybody help me?
    Regards,
    Azra.

    Hi,
    Refer Below links.
    Re: Formatting Excel Attachment output in SO_DOCUMENT_SEND_API1
    Information Broadcasting with Excel Report as attachment
    Zip the excel and send as mail attachment
    Regards
    Md.MaahboobKhan

  • Central Management server - executed a query but how to send the query output in the form of mail?

    Hi All,
    i have used CMS in SQL 2008 R2. i have added couple of servers in its group. i have executed a query & i need to send the query output in the form of email.
    basically query is checking the rows count from couple of user tables in servers.
    issue here is how to copy the data that is used by CMS? i need to work on automate the rows count in difft user table in db servers
    could you please suggest how can i achieve this?

    Copy to what?
    SELECT COUNT(*) FROM sys.objects
    Running the above statement returns two columns (server name and count)
    All the servers SS2005  and onwards , then use
    EXEC msdb.dbo.sp_send_dbmail 
         @profile_name = 'name', 
         @recipients = '[email protected]', 
         @query = 'SELECT COUNT(*) FROM sys.objects', 
         @subject = 'Count rows'
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How do you set up excel form in sharepoint server?

    Dear all,
    I am trying to setup an excel form in sharepoint list, basically something that will do a bit of calculation and it has to be in form format. Just like the excel form. Will it be easier to set it up in a web page or in a list? I will need to run some approval
    on this form too, but that's after I figure out how to set this form up first. I tried infopath, it is very confusing in infopath, is there an easier way to achieve this? Thanks.
    Timothy Liu

    Hi,
    It could be achieved with the feature of the SharePoint OOTB List.
    For calculation like excel forms, you can add some Calculated fields to do the calculation firstly, then you can create a DataSheet
    View in the list, it will allow you edit the list like excel form.
    For approval,  you can enable the approval feature in the list as the following steps:
    “List Settings”->”Version Settings”->” Require content approval for submitted items?”-“Yes”.
    Reference:
    http://www.learningsharepoint.com/2012/07/19/sharepoint-2013-datasheet-view-add-items-add-columns-update-multiple-items-etc/
    http://office.microsoft.com/en-us/windows-sharepoint-services-help/examples-of-common-formulas-HA001160947.aspx
    http://yalla.itgroove.net/2012/09/sharepoint-calculated-column-formulas/
    Feel free to reply if you still have any questions.
    Best regards
    Patrick Liang
    TechNet Community Support

  • Excel form of SAP-BW reports sending via mail as an attachment

    Hi Friends,
    I want to take your opinion about a scenario....
    We access SAP-BW reports in Enterprise portal, there the user can export the report to excel.
    I wish to know if it is possible that the excel form of this report could automatically be sent as an attachment via mail to the outlook accounts of users on a daily basis. Please let me know how.
    Regards,
    Amit Srivastava

    Hi,
    1st you need to congigure the Precalculation server.Inform BASIS people to do that. After that you can check in RSPRECADMIN T-code. There you can see how many servers are there in active(green light). Save your query as workbook and then distribute that workbook from tools menu. -->it will open it in new window. there you can create new setting and then provide Email-ids in 1st tab, and provide subject line and message in 2nd tab, And finally provide variables in 3rd tab. Finnaly save it and Schedule in background by providing date & time. you can use periodic also.
    Regards
    Pcrao.

  • How to send output of  my query in Excel to  inbox  .

    hi,
    1. I have created a query
    2. executed the in RSRT Tcode and set the broad casting setting.
    3. execute the broadcasted settings .
    I got that to my inbox also (only hyperlinlk).
    Now my doubt how to get the output in excel format to my inbox directly .
    I checked the braod caste settings.it only show me MHTML,HTML ,Online link to Current Data
    i do not find an excel option there in broad cast settings.
    Can any one help me...or even docu's......
    Regards
    Laxman

    Hi,
    Goto Transaction :RSRD_ADMIN
    click on "Settings"
    Enter the Technical Name and Descreption of the broadcasting
    in the Basis Object
    type - BQ - query
    technical name - Query Technical name
    Content
    Distribution type - MAIL
    Outputformat - XLS
    and click on F8(Execute).
    Next goback and select Schedule and enter the scheduling parameters and check.
    Regards
    KP

  • Sending output / forms via Fax

    I am trying to configure the output to send our purchase order form via fax.
    I have been been able to sucessfully configure the output via transaction NACE for printing and email.  I have followed the same configuration steps for defining the fax, however, I am unable to successfully create the output.
    The error I receive in the purchase order is "Error in OPEN_FORM for document 45xxxxxxxx"

    No unfortunately it does not provide any additional info.  I am thinking of following the instructions in the following SAP Note (397691) so that I have a better picture of the error: 
    "Symptom
    If errors occur when purchasing documents are output, the system generates an error message in the message log of the message overview.However, error message ME142 'Error in OPEN_FORM for document &' contains only the information that an error occurred and not the error cause.With the attached source code, the error cause is also displayed in the error message (for example, missing authorization, terminated connection and so on)."

  • ALV report output to excel file, zip it and send to email

    my requirement is to run a report then the result will be sent to email. Attachment is an excel file that is zipped since file size is about 25MB
    I've search several forums and found a sap template in sending email with excel file attachment, it is BCS_EXAMPLE_7
    but it should be zipped, what i found is this CL_ABAP_ZIP, but with my understanding, the file needs to be in PDF format to be able to zip
    has anyone had the same requirement before?
    Would be thankful to your input guys, thanks!

    any ideas guys?

  • Output to Excel sheet

    How to copy the contents of output into excel sheet?

    Hi,
    Check the below example, to download the ALV report output to an excel sheet.
    REPORT Z_CONCEPTALV .
    TABLES: KNA1,VBAK.
    DATA: ITAB TYPE TABLE OF VBAK,
    CONTAINER TYPE SCRFNAME VALUE 'ALVCONTROL',
    CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    GRID TYPE REF TO CL_GUI_ALV_GRID,
    L_CONTAINER TYPE SCRFNAME VALUE 'LOGO',
    I_PARENT TYPE REF TO CL_GUI_CONTAINER,
    L_CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE,
    LT_LIST_COMMENTARY TYPE SLIS_T_LISTHEADER,
    L_LOGO TYPE SDYDO_VALUE.
    DATA: OK_CODE(4).
    CALL SCREEN 1100.
    *& Module STATUS_1100 OUTPUT
    text
    MODULE STATUS_1100 OUTPUT.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    CASE OK_CODE.
    WHEN 'DISP'.
    SELECT * FROM VBAK INTO TABLE ITAB WHERE KUNNR = KNA1-KUNNR.
    IF CUST IS INITIAL.
    CREATE OBJECT CUST EXPORTING CONTAINER_NAME = CONTAINER.
    CREATE OBJECT GRID EXPORTING I_PARENT = CUST.
    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME
    = 'VBAK' CHANGING IT_OUTTAB = ITAB.
    ENDIF.
    IF L_CUST IS INITIAL.
    CREATE OBJECT L_CUST EXPORTING CONTAINER_NAME = L_CONTAINER.
    CREATE OBJECT TREE EXPORTING I_PARENT = L_CUST.
    PERFORM BUILD_COMMENT USING LT_LIST_COMMENTARY.
    CALL METHOD TREE->CREATE_REPORT_HEADER EXPORTING IT_LIST_COMMENTARY =
    LT_LIST_COMMENTARY I_LOGO = L_LOGO.
    ENDIF.
    WHEN 'DOWN'.
    PERFORM F_DOWNLOAD_TO_EXCEL.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE. " STATUS_1100 OUTPUT
    FORM BUILD_COMMENT USING LT_LIST_COMMENTARY.
    L_LOGO = 'ENJOYSAP_LOGO'.
    ENDFORM.
    FORM F_DOWNLOAD_TO_EXCEL.
    CALL FUNCTION 'DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = ' '
    CODEPAGE = ' '
    FILENAME = ' '
    FILETYPE = 'DAT'
    ITEM = ' '
    MODE = ' '
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    FILEMASK_MASK = ' '
    FILEMASK_TEXT = ' '
    FILETYPE_NO_CHANGE = ' '
    FILEMASK_ALL = ' '
    FILETYPE_NO_SHOW = ' '
    SILENT = 'S'
    COL_SELECT = ' '
    COL_SELECTMASK = ' '
    NO_AUTH_CHECK = ' '
    IMPORTING
    ACT_FILENAME =
    ACT_FILETYPE =
    FILESIZE =
    CANCEL =
    TABLES
    DATA_TAB = ITAB
    FIELDNAMES =
    EXCEPTIONS
    INVALID_FILESIZE = 1
    INVALID_TABLE_WIDTH = 2
    INVALID_TYPE = 3
    NO_BATCH = 4
    UNKNOWN_ERROR = 5
    GUI_REFUSE_FILETRANSFER = 6
    CUSTOMER_ERROR = 7
    OTHERS = 8
    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.
    Refer these links:
    Export ALV List into Excel Sheet
    How to convert alv list into excel file?
    Reward points if found helpful...
    Cheers,
    Chandra Sekhar.

Maybe you are looking for

  • Time Machine Back-up from External Hard Drive

    Time Machine only back-up what is on my MBP Drive, Can I back-up files from an external usb drive that is connected to MBP to TM??? if no what is a good back-up software to use???? Thanks.

  • Reducing call to a function

    Hello, I have to do some lookup for some fields (let's acll one of them A) in a table (Z). in order to avoid calling the function for all lines, I was thinking of grouping the lines based on the field A, and then, calling the function to do the looku

  • Closing swf loaded into movie clip

    I have built a movie clip on my main flash file that I am loading separate swfs into. On the separate swfs I have a close button, but do not know what action script to attach to it to make the movie clip go away? I want these to go away every time yo

  • HTTP Connection timeout setting

    Hi, I'm using ebXML protocol for B2B 10.1.2.3+MLR 5. I talk to multiple trading partners and when one of the TP is down, we see that there is a pileup of messages in the backend queues. This is because, there is constant message inflow into the JMS q

  • Bridge screen redraw fails updating (major bug ?)

    My bridge window (MacOs10.6.6) is never updating : whatever i do in bridge (select a file, click anywhere), screen stays static. To update the view, i have to move the whole window and hide it out of the screen, or to open menus, or to switch to anot