Display a Excel File

Dear All,
I will like to diplay a Excel file or a Excel sheet in a JSP.
The sheet has a graphic.
Would anyone give me a sample code for this? ( jsp and class )
Thanks,
Jones

This will help .. Enjoy!!
<%@ page errorPage = "/error_handler.jsp" %>
<%
String id = request.getParameter("id");
if (id == null) {
     id = "";
boolean DEBUG_ON = Constants.DEBUGGING;
response.setContentType("application/vnd.ms-excel");
%>
<html>
<head>
<title><%=reportTitle%></title>
<META HTTP-EQUIV="expires" CONTENT="-1">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META name="GENERATOR" content="IBM WebSphere Studio">
</head>
<body>
<table border="0"> <!-- Container table -->
<tr>
<td align="center"><h2><%=reportTitle.toUpperCase()%></h2></td>
</tr>
<tr>
<td align="left">
<%
if(!updateDtStr.equals("")) {
out.print("Last Update: " + updateDtStr);
%>
<br>
<table border="1">
<tr>
<%
int s_index = 0;
Vector r_headings = null;
Vector reportRow = null;
// Get report headings, if supplied separately
if(reportHeadings != null) {
r_headings = reportHeadings;
else {
r_headings = (Vector) reportVector.get(0);
s_index = 1;
if(r_headings != null) {
for(int i=0; i<r_headings.size(); i++)
out.print("<td align=center><b>");
out.print(r_headings.get(i));
out.print("</b></td>");
Utilities.debugPrintln(DEBUG_ON, "headings: " + r_headings.get(i));
%>
</tr>
</table>
<table border="1" BorderColor="black">
<%
// Get report details
if(reportVector != null) {
for(int i=s_index; i<reportVector.size(); i++)
reportRow = (Vector) reportVector.get(i);
out.print("<tr>");
for(int j=0; j<reportRow.size(); j++)
out.print("<td align=center>");
if(reportRow.get(j) instanceof String)
out.print(((String) reportRow.get(j)).trim().equals("") ? " " : (String) reportRow.get(j));
else
out.print(reportRow.get(j));
out.print("</td>");
out.print("</tr>");
if(reportRow != null)
%>
<tr>
<td colspan="<%=reportRow.size()%>"> </td>
</tr>
<%
} // end of if(reportVector != null)
%>
</table>
</td>
</tr>
<tr>
<td align="center">
<br>
<b>Wal-Mart Confidential</b>
</td>
</tr>
</table> <!-- end of container table -->
</body>
</html>

Similar Messages

  • Problem displaying an Excel File: Please Help

    Hello,
    I spent 3 hours this morning reading the forum on how to display an Excel file in the browser using JSP and I apologize in advance if the answer is in the forum.
    I cut and paste many examples: My goal is to display an excel file on the browser.
    Below is the code but the result is a disaster (please se after the code the result).
    My question is how can I display an excel file using the browser. What's wrong with my code. Apparently it worked for many people on the forum.
    Please help. I must do that by tomorrow and I had spent already so many hours.
    THANK YOU SO MUCH IN ADVANCE.
    So far the forum had helped me a lot.
    <%@ page language="java" import="java.io.*" %>
    <%
    String myfile = new String("/temp/temp.xls");
    File fileName = new File(myfile);
    // Setup our streams
    FileInputStream fis = null;
    ServletOutputStream out1 = response.getOutputStream();
    // Set content type and other response header
    response.setContentType(getServletContext().getMimeType(fileName.getName()));
    //response.setContentType("application/excel-document");
    //response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","attachment; filename=\"" + fileName.getName());
    response.setContentLength((int) fileName.length());
    // Read in the file from the correct place and stream it to the user
    int iRead;
    FileInputStream stream = null;
    try
    stream = new FileInputStream(myfile);
    while ((iRead = stream.read()) != -1)
    out1.write(iRead);
    out1.flush();
    } catch (IOException i) {}
    %>
    RESULT:
    ������>�� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���@����\p Yahel Malkin B�a�=���=��@�7 �������Oh��+'��0p08 P \h� Yahel Malkinn@�|�$�+�@�|�$�+�������.��+,��0�HP X`hp x ��� competitivePricingReportSave Worksheets���� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Root Entry�������� �F��T�+�����Workbook������������SummaryInformation(����DocumentSummaryInformation8������������

    For those who are having the same problem than me here the solution:
    In fact I was only interested in saving the file
    <%@ page language="java" import="java.io.*" %>
    <%
    String myfile = new String("/temp/temp.csv");
    response.setContentType ("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachment; filename=\""+myfile+"\"");
    int iRead;
    // Setup our streams
    FileInputStream fis = null;
    ServletOutputStream out1 = response.getOutputStream();
    FileInputStream stream = null;
    try
    stream = new FileInputStream(myfile);
    while ((iRead = stream.read()) != -1) {
    out1.write(iRead);
    out1.flush();
    } catch (IOException i) {}
    %>

  • Oracle reports to display PDF/Excel files stored in the Database

    can we use Oracle reports to view/display PDF/Excel files stored in the Database? Thanks Lalitha

    A document stored in the database can be easily retrieved in or via the browser using mod_plsql. Simplified:
    select content, mime_type
    into v_blob, v_mime_type
    from ...
    owa_util.mime_header(nvl(v_mimetype,'application/octet'),false);
    htp.p('Content-length: ' || dbms_lob.getlength(v_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(v_blob);So, the link in your report should point to this database procedure.
    Edited by: InoL on Mar 1, 2011 4:17 PM

  • How i will display an Excel file in java

    Hi,
    I have an excel File, Now i want to show it from java, i can do it by clicking an button. So when i will click a button then it will display that excel file thatt means it will be open. Is there anybody can help me?
    Please give me a sample. I need thid urgently. Please help me.
    With regards
    Bina

    look in your "jexcelapi_2_5_9" package, in order to print you have to have something that understands the file strucuture of the object you want to print--ie knows what an excel file is.

  • How can i display a excel file generated by labview?

    hello,
    I'm looking for an exemple to display (open) a .xls file generated by labview after simulation but without use  the tookit report generation.
    somebody knows how could I do this?
    Any suggestions?
    Thanks,
    longar
    p.s: i use labview 8.6 
    Solved!
    Go to Solution.

    There is quite large dedicated Excel thread with a lot of examples.
    I'm curious though. If you don't have the toolkit, how did you create the Excel file in the first place?

  • Best ways to view/display PDF/Excel files stored in the Database

    What are best ways to display/view PDF/Excel files stored in the Database? thanks L

    Thanks tom, sorry let me explain. Currently we have oracle forms screen, using webutil to store/view files into DB. client won't like the interface, they want us to make it more friendly, drag and drop if possible, load multiple files, as possible.. So I am exploring different ways to improve may be java (or jdev/any any other), different screen designs, different features for fileupload/download/view options.

  • Problem with french character display in Excel file

    In my program I am exporting the french content into one excel file (.csv)through the following code but the characters in french are not getting displayed properly. Please let me know what is the issue
    I have checked the contents that is being written in "fileName"
    It is French only. But when the file is downloaded to desktop, it is showing junk characters in .csv file
    ============
    if (fileName != null) {
    File theFile = new File(fileName);
    if (theFile != null) {
    try {
         byte[] bytesFromFile = exportUtil.getBytesFromFile(theFile);
         response.setContentType("text/csv; charset=UTF-8");
         response.setHeader("Content-Disposition",
              "inline;filename=" + theFile.getName());
         response.setContentLength((int) theFile.length());
         ServletOutputStream sos = response.getOutputStream();
         sos.write(bytesFromFile);
         sos.flush();
         sos.close();
    } catch (IOException e2) {
         e2.printStackTrace();
    }

    Have you confirmed that the file you are copying to the response is actually encoded in UTF-8? Because you're telling the server that it is. If it's in some other charset then naturally it isn't going to look right.

  • IMac 2.66 Radeon HD 2600 Pro: some Excel files won't display in ppt decks

    Running Leopard 10.5.8 and MS Office 2004
    Two iMac (8.1) 2.66 GHz with ATI Radeon HD 2600 Pro video won't display some Excel files in PowerPoint decks, but iMac 1.83 GHz Core Duo will display o.k. as will MacBook Pro, MacBook, etc. Installing a trial version of Office 2008, both iMac 2.66 GHz display the PowerPoint files o.k.
    I could downgrade the users to Intel iMac 1.83 GHz, or buy two copies of Office 2008 and support them, neither of which is a great solution.
    Looking for a simple fix or workaround on what seems to be a video card issue. Don't seem to see this problem or a fix on the ATI site. I've googled this but haven't run into a similar issue.

    Well, Office 2008 is only $110 USD at http://www.amazon.com/Microsoft-Office-2008-Home-Student/dp/B000X86ZAS/ref=sr11?ie=UTF8&s=software&qid=1251560959&sr=8-1
    That seems the least expensive solution to me.

  • Display Excel File using OfficeControl

    Hi,
    My requirement is to display and Excel file for approval purpose which is generated by custom ABAP application. After each approval I need to again generate the Excel file with the approval name added and send for next approval.
    Is it possible to download the Excel File to application server and display it on webdynpro screen.
    Please let me know if they are other methods to achieve the same.
    Thank you,
    Ramu N.

    Hi Ramu,
    Yes you can do this by using File upload and  download methods. using this you can upload and download excel files.
    Check this wiki..
    http://wiki.sdn.sap.com/wiki/display/WDABAP/UploadandDownloadfilesinWebdynproABAP
    http://wiki.sdn.sap.com/wiki/display/WDABAP/ExcelFileUploadAndDisplayDataUsingWebDynPro+ABAP
    using office control...Check this...
    How to use element FILE_UPLOAD with element OFFICE_CONTROL
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/af8841349e1909e10000000a155106/frameset.htm
    Cheers,
    Kris.
    Edited by: kissnas on May 19, 2011 6:36 AM

  • Problem excel file display in my workset ...

    Hi everybody,
    I create a Workset, a page and a basic iview about an URL.
    It works.
    Then, i create an iview (template KM document) which must display an excel file.
    I add to my Page and i visualize a glimpse: i see the right excel file in an HTML window.
    Problem appears when i execute my workset ... It doesn't work. I see a blank page!
    Any suggestions ?
    Thanks,
    Rodolphe.

    Hi,
    I have checked the SU3 for user settings.
    But, that doesn't seem to work.
    Also, i checked macros in excel and Format cell options.
    Thanks,
    Ashok
    Edited by: koash08 on Mar 4, 2011 6:40 PM

  • How to edit a spreadsheet (excel file) in the portal?

    Hello experts,
    at the moment i am working on the requirement to edit a spreadsheet in the portal.
    Until now i was able to display an excel file with the help of the 'KM Document iView (without content filter)'.
    Everything is displayed alright and i can perform changes in the spreadsheet.
    BUT: There is no such thing like a Save-Button or something like that. Does the SAP NW Portal already provide a solution for this requirement? Or will i have to develop an own application?
    I have already searched the forums and sap help, but i haven't found any solution. I can't imagine that such an easy requirement would need coding.
    Best Regards
    Marcus
    (Po*nts will be rewarded for good answers)

    Hi Marcus,
    I do not think you can do the task the way you want. You will have to look for some workaround that may be download the file, edit it and then upload it back. You will have to code in your application for that. If you want to do this way I can help you further to edit and save the excel.
    Regards.
    Rajat

  • Opening Excel  files from a JSP page

    Hi,
    I am not able to open up an Excel file through JSP.
    I am using following code snippet in JSP page
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","inline; filename=Test.xls");Do i need to do additional settings for rendering Excel from a JSP
    Thanks in advance !!!

    Hi,
    In my application , we have Excel files on the server i.e we are not creating excel sheets.
    I just want to display these static excel files through a jsp.
    I am able to display the excel files by reading them into ByteArrayOutputStream
    <%
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","attachment; filename=B.xls");
    ServletOutputStream so = response.getOutputStream();
    String filename = "D:\\Test.xls";
    String mimetype = "application/vnd.ms-excel";
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    InputStream in = new BufferedInputStream(new FileInputStream(filename));
    byte bytebuff[] = new byte[500];
    for(int lengthread = 0; (lengthread = in.read(bytebuff)) != -1;){
    output.write(bytebuff, 0, lengthread);
    byte data[] = output.toByteArray();
    response.setContentType(mimetype);
    so.write(data);
    in.close();
    so.close();
    %>But my question is that , do i really need to do all this for rendering excel through a jsp.
    Can't i do it by just setting the content type ?
    Thanks

  • Download ALV into excel file

    Hi experts,
                   I used subtotals in ALV.first three columns I claculated based on the addition of individual column.In fourth column i calculated the value based on three calculated values ...It is  not problem.
              when i download this into excel file the original value is only coming .the calculated value i.e) calculated based on three values didnt get displayed in excel file..Help me please...
    Thank u,
    Manjula Devi.D

    Hi.
    I find that
    List > Export > Spreadsheet
    gives no subtotals, but
    List > Export > Local File and then Spreadsheet
    does give subtotals.
    I find that
    Views > Microsoft Excel
    followed by
    Save As
    does give subtotals.
    John

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

  • Report to display PO details and download details in an excel fil

    Hi,
    I have been asked to develop a report for "Develop report to display PO details and download details in an excel file".
    Could any one guide me technically what are the different tables i need to take to generate the report. Treat this is very urgent. Pls provide sample code too....
    Thanks in advance....

    Purchase Order PO
    Tcode for creation ME21,ME22,ME23. tables EKKO,EKPO.
    refer this program
    REPORT ZPOCHANGE.
    This is a subroutine perform in the Purchase order Layout sets.
    Description :  To retreive the details of changed remarks in PO output and to capture the retrival date
                         Additional features with the previous changed appearing.  e.g. from .... to
    Note        :  If the latest modification details required
    Please Uncomment the lines mentioned under  'Last Modified Remarks only'
    Information
    /: PERFORM CHDATE IN PROGRAM ZPOCHANGE
    /:               USING &EKKO-EBELN&
    /:               CHANGING &RVDATE2&
    /: ENDPERFORM.
    /: IF &RVDATE2& EQ ' '.
    /  Revision Date: NIL
    /: ELSE.
    /  Revision Date: &RVDATE2&
    /: ENDIF.
    Main Window
    /E CHANGE_REMARKS
    /: PERFORM CHDET IN PROGRAM ZPOCHANGE
    /:            USING &EKPO-EBELP&
    /:            USING &EKKO-EBELN&
    /:            USING &T166T-CHTXT&
    /:            USING &T166T-CTXNR&
    /:            CHANGING &ITAB1-F_NEW&
    /:            CHANGING &ITAB1-F_OLD&
    /:ENDPERFORM.
    /:IF &ITAB1-F_NEW& NE ' '
    =  &ITAB1-F_OLD(C)& CHANGED TO &ITAB1-F_NEW(C)&
    /:ENDIF
    You might need to apply Note 373524 - Message determination and printing
    TABLES : CDSHW , "Change documents, formatting table
             CDHDR , "Change document header
             EKPO  , "Purchasing Document Item
             EKKO  , "Purchasing Document Header
             T166C . "Print-Relevant Purchasing Document Changes
    DATA   : ITAB1 LIKE CDSHW OCCURS 100 WITH HEADER LINE.
    DATA   : ITAB2 LIKE EKPO  OCCURS 100 WITH HEADER LINE.
    DATA   : DOCUM LIKE EKKO OCCURS 100 WITH HEADER LINE.
    DATA   : TABKEY LIKE CDSHW-TABKEY.
    data    : begin of ctab occurs 10,
              tname like t166c-tname,
              fname like t166c-fname,
              TABKEY LIKE CDSHW-TABKEY,
              FLAG(3),
              end of ctab.
    DATA   : VAL1(15), VAL2(15).
    DATA : M1(20), M2(10), M3(10),M4(5).
    DATA : RVDATE(10),RVDATE2(10) , EBELN LIKE EKKO-EBELN, COUNT TYPE I.
    Text number for change text(CTXNR), CHANGE TEXT(CHTXT), Purchase order
    Number and item number are passed from Layoutset
          FORM CHDET                                                    *
    -->  ITAB                                                          *
    -->  OTAB                                                          *
    FORM CHDET TABLES ITAB STRUCTURE  ITCSY
                      OTAB STRUCTURE  ITCSY.
      LOOP AT ITAB.
        CASE ITAB-NAME.
          WHEN 'T166T-CHTXT'.
            MOVE ITAB-VALUE TO M1.
          WHEN 'T166T-CTXNR'.
            MOVE ITAB-VALUE TO M2.
          WHEN 'EKKO-EBELN'.
            MOVE ITAB-VALUE TO M3.
          WHEN 'EKPO-EBELP'.
            MOVE ITAB-VALUE TO M4.
        ENDCASE.
      ENDLOOP.
    Throught this function change details are retrived into itab1.
      CALL FUNCTION 'ME_CHANGES_READ'
           EXPORTING
                DOCUMENT_CATEGORY = 'F'
                DOCUMENT_NUMBER   = M3
           TABLES
                XCDSHW            = itab1.
      SELECT SINGLE * FROM T166C WHERE CTXNR = M2.
      IF SY-SUBRC = 0.
        CONCATENATE M3 M4  INTO TABKEY.
    ********Last Modified Remarks only**********************
       read table ctab with key  tname  = T166C-TNAME
                                         tabkey  = tabkey
                                         fname   = T166C-FNAME.
       if sy-subrc ne 0.
        LOOP AT ITAB1 WHERE TABNAME = T166C-TNAME
                                      AND   TABKEY+3(15) = TABKEY
                                      AND   FNAME = T166C-FNAME.
    *********Last Modified Remarks only**********************
           ctab-tname  = t166c-tname.
           ctab-fname  = t166c-fname.
           ctab-tabkey = tabkey.
           append ctab.
          delete itab1.
          exit.
        endloop.
    Captured details are exported to Layoutset
        LOOP AT OTAB.
          CASE OTAB-NAME.
            WHEN 'ITAB1-F_OLD'.
              OTAB-VALUE = ITAB1-F_OLD.
              MODIFY OTAB.
              CLEAR : ITAB1-F_OLD.
            WHEN 'ITAB1-F_NEW'.
              OTAB-VALUE = ITAB1-F_NEW.
              MODIFY OTAB.
              CLEAR : ITAB1-F_NEW.
          ENDCASE.
        endloop.
      endif.
    ******Last Modified Remarks only****************
    ENDIF.
      clear ctab.
    ENDFORM.
          FORM CHDATE                                                   *
    -->  ITAB                                                          *
    -->  OTAB                                                          *
    Form for revision date retrival. PO no. is passed from layoutset
    and in the change document header latest modified date is captured
    and passed to revision date field in Layoutset.
    FORM CHDATE TABLES ITAB STRUCTURE  ITCSY
                      OTAB STRUCTURE  ITCSY.
      CLEAR : RVDATE, EBELN.
      LOOP AT ITAB.
        CASE ITAB-NAME.
          WHEN 'EKKO-EBELN'.
            MOVE ITAB-VALUE TO EBELN.
        ENDCASE.
      ENDLOOP.
    SELECT UDATE INTO CDHDR-UDATE FROM CDHDR WHERE OBJECTCLAS = 'EINKBELEG'
                                                       AND OBJECTID = EBELN.
        IF RVDATE < CDHDR-UDATE.
          RVDATE = CDHDR-UDATE.
        ENDIF.
        COUNT = COUNT + 1.
      ENDSELECT.
      LOOP AT OTAB.
        CASE OTAB-NAME.
          WHEN 'RVDATE2'.
         CONCATENATE RVDATE6(2) '.' RVDATE4(2) '.' RVDATE(4) INTO RVDATE2.
            IF COUNT = 1.
              RVDATE2 = ''.
            ENDIF.
            MOVE RVDATE2 TO OTAB-VALUE.
            MODIFY OTAB.
        ENDCASE.
      ENDLOOP.
    CLEAR : COUNT.
    ENDFORM.
    Message was edited by:
            Karthikeyan Pandurangan

Maybe you are looking for

  • How can I get an app from the itunes screen to my ipad

    The app shows up in the itunes apps but how can I get to show up in my ipad

  • 00/00/0000 Date

    Hello, I want to insert 00/00/0000 as a default date in a date field. Can you please tell me how to achieve this? I know it is not a valid date. Regards

  • WHY does firefox come up when I had a attack on my pc as the sender?

    while on Facebook and trying to view uploaded video...my NORTON blocked several attacks ,when I checked who was sending viruses (x6), I discovered that the IP matched Firefox as the sender...I find this to be unfair as well as preposterous and a bull

  • GRC AC Security/Backend Access

    My collegue and I are not Security or Basis and need to know what we will be accessing/touching on the SAP backend so that we can get the appropriate security access within our organization.  Can anyone please respond by indicating what known transac

  • Matrox g200 Video Card, mga driver not working in Xorg7

    Hello!  This is my first post in the forum...greetings everyone! So I'm trying to get a Matrox g200 Video Card working -- but I get an error mga_hal module missing... I've done a few searches and come up basically empty.  I have seen from another use