JSP TO MS EXCEL

I have my table in my JSP page. Let me know how to export the contents of a table to microsoft excel sheets.

Check these "excel" posts:
http://onesearch.sun.com/search/onesearch/index.jsp?col=developer-forums&qt=excel&site=dev&dftab=siteforumid%3Ajava54%2Csiteforumid%3Ajava31%2Csiteforumid%3Ajava553&cs=false&rt=true&chooseCat=javaall&subCat=siteforumid%3Ajava54%2Csiteforumid%3Ajava31%2Csiteforumid%3Ajava553

Similar Messages

  • OPEN JSP IN 2007 Excel

    I am trying to open JSP file in excel and I get the following message: excel cannot open the file because the file format or file extension is not valid.Verify that the file has not been corrupted and that the file extension matches the format of the file. By the way, I have MS excel 2007.
    here's my method:
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("content-disposition","attachment; filename=Report.xlsx");
    Also, I have add the following to web.xml:
    <mime-mapping>
    <extension>xlsx</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
    Could u pls resolve the issue asap.
    smruti

    SMRUTIMOHANTY wrote:
    Yes, i m generating a report in jspYou're generating a report with JSP? Rather use a Servlet for that.
    but i am not able to publish that report to excel page with extension .xlxs.
    With .xls i m publish the this report sucessfully.
    while opn report with extension .xls , i m getting warning mesg.
    pls help me out.First of all: are you actually generating an Excel report using some Excel API (JExcelAPI or Apache POI HSSF), or are you just sending some HTML to the client and fooling the client that it is an Excel file by changing the response headers?

  • Export jsp content to Excel -- how to keep leading zero?

    Hi:
    I am trying to export a JSP content to Excel by using
    response.setContentType( "application/vnd.ms-excel" );
    response.setHeader( "Content-disposition", "attachment; filename=pc.xls" );
    it was working great except my jsp has a field whose value consist of leading zero. i.e. 000XXX. Excel strips the leading zero, but I would like to keep them. Please advise.

    hi Chang,
    Can you please check my thread http://forum.java.sun.com/thread.jspa?threadID=737238&tstart=0
    I think you might know the answer since it is similar functionality but for text files.
    Thanks !

  • How to send the data from jsp page to excel ???

    hi all,
    i want to send the data from my jsp form to excel sheet. any one can help me ??

    Hope this sample code might help :
    StringBuffer data = new StringBuffer();
    OutputStream ostream = response.getOutputStream();
    response.setContentType("application/vnd.ms-excel");
    response.setHeader( "Content-Disposition",
    "attachment; filename=sample.xls" );
    ostream.write(data.toString().getBytes());
    ostream.flush();
    Try it out.
    Swathi

  • How to export data in JSP to MS excel

    hi frens..
    anyone out there knows how to export data in JSP to Ms excel .. i already add this code inside my jsp..
    <%@ page contentType="application/vnd.ms-excel" %>i need to retrieve the data from the database to excel.. it's something like a report display in the excel.

    set the response type as....
    response.setContentType("application/vnd.ms-excel");
    U must be geting the data from the database...
    get the data ...
    rs=st.executeQuery(sql);
    where sql is ur query and use it as usual....

  • How to export only the data displayed in table of a jsp page to Excel

    Hi All,
    I want to export only the data that is displayed in the table of a jsp page to excel. But with my current code everything is getting exported to excel.
    <input type="checkbox" name="download" onclick = "form.submit()"/> Export to Excel
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-disposition", "inline; filename=fileName.xls");
    the table is displayed in the jsp using the following code:
    <table cellspacing="2" cellpadding="3" border="1"
    width="100%"> <tr> <%for (int i = 2; i <= cols; i++) {%>
    <td>
    <%
    out.println( rsmd.getColumnName(i) + " ");
    } %>
    <% while (rsettaba.next ())
    out.println("<tr>");
    for (int j= 2; j <= cols ; j++) {
    //out.println("<td>"+rsetallcl.getString(j)+"</td>");
    String varnl = rsettaba.getString(j);
    if ( varnl == null )
    out.println("<td> Empty </td>");
    else
    out.println("<td>"+rsettaba.getString(j)+"</td>");
    out.println("</tr>");
    %>
    </td>
    </tr>
    </table>
    please can anyone help how to just extract only the data in the table of a jsp page to excel.
    Edited by: Ramky48 on Dec 9, 2009 9:51 PM

    Ramky48,
    Why did you open a new thread when you had gotten quite a few responses and suggestions on the [url http://forums.oracle.com/forums/thread.jspa?threadID=998411]thread where you asked the same question - seems the best thing to do would be to continue on the same thread?
    However, your question has nothing to do with JDeveloper/ADF. If you'd like to do it the ADF way, it's trivially easy - you can use the [url http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_exportCollectionActionListener.html]af:exportCollectionActionListener component, which does what you are asking for. If you want to use a straight JSP way, there were several good suggestions in the other thread you opened, or Googling "jsp export to excel" will get you about 4.6 million hits; the first 10 or so look pretty promising.
    John

  • Number stored as text (in jsp report with excel output)

    Hi
    I created a jsp report for excel output. I see that the numbers are left aligned with a green traingle on the top of each cell. Was just wondering how can I resolve this and have my numbers displayed as numbers - right aligned and with no green triangle. Is there some setting I have to make explicitly so that numbers appear as numbers in excel output?
    Thx!

    Hi Sasidar,
    In Excel right click the column select format cells and then select  the format as text which is general by default.
    Regards,
    Anil.

  • How To Save JSP Page As Excel File.

    Dear Friends,
    I am working on a project which has oracle as backend. I have some reports in my project.(.jsp files)I want to save it in MsExcel format.
    How could i do it?
    Also is it possible to save jsp files (the output genrated by jsp) in MS Word,PDF format?
    Sameer.

    If you set the content type and are using IE then the HTML will be rendered in Excel in place. Other browsers open Excel, but not in place.
    If you need more info search google for 'java setcontenttype excel':
    <% response.setContentType("application/vnd.ms-excel"); %>Also a much easier and flexible way to create html from ResultSets is to use my free FormattedDataSet API. The following one line would replace all the lines you posted (and the ones you didn't such as opening the Connection, Statement and ResultSet).
    FormattedDataSet fds=FormattedDataSet.createInstance();
    String html=fds.getFormattedDataSet("select * from table", "htmlTable");steve - http://www.fdsapi.com - The easiest most flexible way of generating dynamic HTML and XML.
    The following would be replaced.
    <table>
    <tr> <th>Name</th> <th>Employee No</th></tr>
    <tr>
    <%
    while (rs.next())
    %>
    <td><%=rs.getString(1) %>
    </td>
    <td><%=rs.getString(2) %>
    </td>
    <%
    %>
    </tr>
    </table>
    **

  • Oracle Report vs JSP efficiency and Excel XML in Web Source Questions

    I have used Oracle Reports in the past 6i, but haven't used them in about 4 years. We are now using 9.0.4 reports and I am trying to generate Excel XML from an Oracle report by manipulating the web source of the report. Basically copying and pasting the Excel XML into the web source of the Oracle Report instead of html as suggested by this Metalink Doc ID 240819.1. I do have a JSP working example that generates Excel XML created in JDeveloper and successfully spawns off a very nice looking Excel spreadsheet.
    However, a statement was made here by our app sever guy that an Oracle Report is more efficient at getting data from the database than a JSP. The app sever section does not want anyone using JSPs to generate a report of any kind. I guess small web pages are OK since our java guys use them all the time. This rule for a Reports only environment seems a little restrictive to me. Is there any truth to the statement that Oracle Reports bulk collects data in one chunk as opposed to a JSP making multiple trips to the database from the middle tier?
    Secondly, if an Oracle Report is more efficient in the way that it collects large record sets from the db, and if I save an Oracle Report as a JSP not an rdf, and use the reports_tld.jar with the rw tags instead of the typical jsp jstl tags, will I still get the same improvement from using an Oracle report? I guess the improvement is in the library used correct?
    Thirdly, although not part of this forum, I also am assuming that if we have single sign on that when I call a JSP from an Oracle Form I will not have to log in again correct?
    Thanks...
    Message was edited by:
    Mark Reichman

    It could be the configuration issue. Reconfigure the engine.

  • Exporting Content of a JSP page into Excel Spread Sheet

    I am trying to export the content of a JSP page into an excel spread sheet. I know this issue had been posted before, but if you any one has the source code of a sample that's working please send it to me at [email protected]
    Your help is appreciated.
    Jamais.

    http://forum.java.sun.com/thread.jspa?threadID=664249

  • JSP results on excel (.xls)  file

    Hi all,
    I want to have a link on a jsp file which would display the contents of the .jsp on an (.xls) file
    I know some webpages allow this like yahoo finance does.
    Can anyone please help me with this and let me know how to approach it .
    Thanks in advance,
    Peter

    ....it's all about the content-type...
    I'm going to bet that you haven't written an xls generator in Java... so we'll go with the next best option.... by default excel is associated with csv, so you can look at whatever mime type is assigned to csv and hopefully Excel will be used to open it.. a quick search reveals: "application/vnd.ms-excel" as the mimetype.

  • Displaying jsp page in Excel

    I'm having trouble getting a jsp page to display in Excel.  Below is the code.  Any idea what I'm missing?
    Thanks in advance,
    John
    <%@ taglib uri= "tagLib" prefix="hbj" %>
    <jsp:useBean id="rbpTable" scope="application" class="com.halliburton.esg.erp.zelc.bdvipp.htmlb.ViewRevenueByParticipantTable" />
    <%
         request.getServletResponse(false).setContentType("application/vnd.ms-excel");
         request.getServletResponse(false).setHeader("Content-Type","application/vnd.ms-excel");
         request.getServletResponse(false).setHeader("Content-Disposition", "attachment; filename=test.xls");
    %>
    <hbj:content id="myContext" >
    <hbj:document>
       <hbj:documentHead title="sap">
              <meta http-equiv="Content-Type" content="application/x-msexcel; charset=ISO-8859-1">
       </hbj:documentHead>
      <hbj:page title="Template for a portal component">
       <hbj:form id="myFormId">
            <hbj:button
                  id="printButton"
                  text="Print"
                  tooltip="Print"
                  onClientClick="javascript:window.print();"
                  width="10"
                  design="EMPHASIZED">
            </hbj:button>
            <hbj:button
                   id="closeButton"
                   text="Close"
                   tooltip="Close"
                   onClientClick="javascript:window.close();"
                   width="10"
                   design="EMPHASIZED">
              </hbj:button>
            <BR><BR>
    <%
          java.text.DecimalFormat df = new java.text.DecimalFormat("#,##0");
          String revenueString = "Total Assigned Revenue: $"+df.format(rbpTable.getTOTAL_PLAN());
    %>
              <hbj:textView text="<%=revenueString%>" design="EMPHASIZED" />
             <hbj:tableView
                   id="myTableView"
                   model="rbpTable.model"
                   design="STANDARD"
                   headerVisible="true"
                   footerVisible="false"
                   fillUpEmptyRows="false"
                   selectionMode="NONE"
                   visibleFirstRow="1">
             </hbj:tableView>
        </hbj:form>
      </hbj:page>
      </hbj:document>
    </hbj:content>

    It´s so easy print your results from a JSP in excel.
    By default the mime type of the jsp is HTML, but you can change it, only have to add the next line in your jsp.
    <%@ page contentType="application/vnd.ms-excel" %>
    that is a example that you can try :
    <%@ page contentType="application/vnd.ms-excel" %>
    1997 1998 1999
    12.3 13.4 14.5
    will load Excel and show this:
       A     B    C
    1
    2
    3 1997 1998 1999
    4 12.3 13.4 14.5
    Good luck!
    Josue Cruz
    PS.Dont forget to reward points

  • How to disable Format Warning when displaying JSP in Excel under MS-Office

    We have an application running in WebSphere 6.0 container, the application displays jsp data in Excel, it had no problem before MS-Office 2007 was install. However, after MS-Office 2007 is used, following format warning dialog box is always displayed:
    The file you are trying to open, ’Requests[1].xls’, is in a different format than specified by the file extension.
    Verify that the file is not corrupted and is from a trusted source before opening the file.
    The user has to click the "Yes" button before the Excel report can be successfully displayed. This is not acceptable by our production users, and I need your helps to get rid of this dialog box.
    The application uses struts. The Action class retrieves data from database and the data is forward to the result jsp
    in an data object set in an attribute of the session's Request object. The Action class also set the display info, such as the contentType,etc., in session's Response object (please see below for details).
    The result jsp retrieves data from the data object and display in Excel according to the display info provided in the
    session response object.
    To eliminate any possible problem that may be caused by the data, I have simplified the result jsp by removing original
    codes (such as data object forwarded from Action, and Tag Library, etc.), and just hardcoded few data for displaying in Excel, however, the same format warning box still always shows up.
    My Action class set display info as below:
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");
    response.setHeader("content-disposition","attachment; filename=Requests.xls");
    My simplified result jsp is listed below:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <!-- <%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt'%> -->
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <TABLE border="1">
         <TBODY>
         <TR>
         <td><p align='left'>myData1</p></td>
         <td><p align='left'>myData2</p></td>
         <td><p align='left'>myData3</p></td>
         <td><p align='left'>myData4</p></td>
         </TR>
         </TBODY>
    </TABLE>
    </BODY>
    </HTML>
    So, I reduced the result jsp to contain only few hardcoded data, but the format warning always shows up. Is it caused by inconsistency between the MS-Office 2007 browser and the JSP engine in WebSphere 6.0 Web container? Need your help to resolve this problem.
    Thanks in advance.

    That's the caveat of fooling your webbrowser and Excel with a plain HTML page along an Excel content-type and Excel extension.
    Don't do that. That's plain stupid. Provide a real binary Excel file. You can create one using Apache POI HSSF or Andy Khan's JExcelAPI. Alternatively -and more recommended in case of large reports-, just use the CSV format. It's easy to create a CSV file in 20 lines of code and Excel perfectly understands CSV formats. Don't forget to change content-type to CSV.

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Export JSP to Excel : Weird problem  (Urgent)

    Hi,
    Sorry for the length of question.
    I am facing a bit weired problem while exporting my JSP report to Excel.
    I have multiple tables in my JSP page .( Use of Multiple tables is a requirement .).
    I am using Struts and Oracle 9i JDeveloper for developement.
    I have a button called "Excel" and on its click , I am opening the same JSP page in a pop up and passing reqd. parameters to it using querystring
    ( sometimes I am keeping the parameters into session as the length is loo large to fit into queryString. )
    I am using
    response.setContentType("application/vnd.ms-excel");
    to transform my JSP page to Excel.
    Sometimes, this works fine.
    But, mant times this gives error such ( in Windows2000 Adv. Server ) as
    "Memory could not be "read"."..with the tile of error-popup as "Excel.exe".
    (In Windows NT , it never exports to Excel. Every time it gives "Dr. Watson Debugger" message box.)
    In Windows2000 Adv. Server ,
    While debugging, I observed that when I click on Excel button, the pop up opens and executes the page and again goes to the start of the page and executes again and thus tries to open the same Excel document.
    As we know, we cannot open same Excel document twice. Hence it gives a popup alert that
    " The file <filename with its entire path> could not be opened.
    There may be several reasons :
    You might be trying to open a file which does not exist.
    You might be trying to open the file which is already open. ..."
    etc.etc. and something like this.
    Now, this is totally unpredictable. If I click Excel button, It may open the file in excel and on next try it would give error.
    This is quite annoying. I searched on this forum, Google but could not find the solution yet.
    I cannot use POI - HSSF . I cannot use userdefined Excel tags as well. as it will require a lot of reqork and unfortunately I don't have that much time now.
    Please help me and let me know how would I be able to successfully and predictably export my JSP pages to Excel.
    Thanks,
    Swipsy.

    Hi,
    Why don�t you save as attachment? (use -> <% response.setHeader("Content-Disposition", "attachment; filename=\"name.xls\""); %> scriplet )...
    I�m doing the same work, but I have problems to export images to Excel by this method...
    Someone could help me??
    thanks a lot

Maybe you are looking for