Open an excel file from jsp

Hi,
I want to open an excel file on click of a link in the jsp.
At present iam using href which i feel is not correct as it is not able to recognize the excel format and paints the entire screen with special characters.Can anyone please help me out.
Thanks,

In your server, there should be some way to tell the server the mime type of a file based on the file's extension. So, you tell the server for every file with the extension of .xls, it should use the mime type of application/vnd.ms-excel. Then, when the link is clicked on, the browser will receive the mime-type message of application/vnd.ms-excel and will open Excel to work with the file.
Hope this helps,
Ron

Similar Messages

  • Opening an excel file in jsp

    how do you open an excel file in my jsp and target it to a table?

    can't it be done using the file class?
    i just want to open the excel file, that's all--
    Open means what ?
    See if this is useful
    String myDB =  "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/book.xls;"
        + "DriverID=22;READONLY=false";
    //con=DriverManager.getConnection("jdbc:odbc:myExcel");
    con=DriverManager.getConnection(myDB,"","");
    dbmd=con.getMetaData();
    stat=con.createStatement();
    rs=stat.executeQuery("Select * from `Sheet1$`");//[Sheet1$]--
    I think it is not possible with File class. and if it is so
    then how you are going to handle the data ?

  • Display excel file from jsp

    hi i am trying to read an excel file from a location on the app server and display it in the browser (ie). the excel file should open up and not display the open/save dialog.
    following is the code that i am using. i am not able to get it to work. getting an illegalstateexception and also i am getting all garbage diplayed in the browser. no excel. kindly help.
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"%>
    <%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire" %>
    <%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
    <%
    //response.reset();
    //response.setHeader("Pragma", "no-cache");
    //response.setHeader("Cache-Control", "no-cache");
    //response.setDateHeader("Expires", 0L);
    ServletOutputStream so = response.getOutputStream();
    String filename = "C:\\example1.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();
    %>

    A JSP calls getWriter() by default.
    Every time you have a carriage return outside <% %> it gets written to the writer.
    The Illegal state exception would be because you are getting the outputStream after the writer.
    This is better done in a servlet, but can be done in a JSP, try it with code like this:
    <%@ page import="java.io.*" contentType="application/vnd.ms-excel"
    %><%@ taglib uri="/WEB-INF/tlds/sapphire.tld" prefix="sapphire"
    %><%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"
    %><%
    %> Note that there is no text at all outside of the <% %> (not even carriage returns)
    Also, why are you writing to a ByteArrayOutputStream (ie into a memory byte array), and then writing the byte array to the servletoutputstream?
    Just put a buffer around the servlet outputstream and write directly to that.
    ServletOutputStream so = response.getOutputStream();
    BufferedOutputStream output = new ByteArrayOutputStream(so);
    ...

  • I want to open an excel file from a folder in the Microsoft live office on Hotmail. Their instruction is to go to tools in Firefox, go to plug-ins and then install Microsofts Office 2010. Can't find plug-h. Help?

    I have uploaded an excel file from my desk top to the Windows Live (HOTMAIL?) office suite. When I try to open the file I get an error that says my system is not supported. My system passes all of the listed criteria except for one. That is a plug in from Firefox. The instructions say to go to the Firefox menu, click on tools then plug-ins. Of course when I go to tools plug-ins is not immediately available, but when I do go to plug-ins, I am to click on Microsoft Office 2010. This plug in is supposed to allow earlier versions of office documents to be viewed as well as Office 2010. The plug-in is not available. When I search the Firefox website I am not able to find such a plug-in.
    I am using Microsoft XP, Office 2007 and the version of Firefox prior to V4. V4 does not support all of my e-mail clients so am not able to use V4.

    I am using Microsoft XP, Office 2007 and the version of Firefox V4 but I have this same problem.

  • Office 2013 can't open word, excel files from the network after upgrade to 8.1

    Hello,
    Recently, I upgraded all PCs from WIN 8 to Win 8.1. After the upgrade I noticed that I can't open any word documents and excel files. Before the upgraded I have no problem opened any files. All PCs have over 500GB free space on hard drive. Other PCs that
    run Win 7 have no problem open them only the one with Win 8.1. This is what I got:
    I right click--> property and there is no unblocked. All files resided on the network server.
    Please help.
    Jimmy

    Hi Jimmy,
    Did you get any error message when you try to open an Excel file/Word document?
    If so, you can post the error message and  event log here.Also ,if you had antivirus software installed, try to disable them to test this issue.
    In addition, what happens if you add the network server location as a trusted location?
    Wind Zhang
    TechNet Community Support

  • Opening new excel file from available Template-Urgent

    Hi Friends,
    I have the functionality like this. I have one excel template. In that i am getting two text files(header and row values) and filling it on the excel file. After that i am doing operation on it. These things i have succeded already. The problem is i am opening the excel file like this
    Process pro = Runtime.getRuntime().exec(strExcelPath+" "+"..\\std\\app\\client\\resource\\SkillReport.xlt");
    when i am opening like this it is opening the tempalte for editing in stead of getting new instance from it. Can any one help me to get a new instance in stead of opening the template itself.

    Thanks guys. I've found another way of doing the same.

  • How to open an excel file from labview?

    I tried to use "open file" vi from File I/O -- Advanced file functions to open an excel file in LabVIEW. Why the excel file wouldn't open after I run the program?

    In addition to ActiveX, you can also manipulate Excel data files using the Windows ADO interface - a technique that is more robust, faster and IMHO easier. Do a search on the forum as there have been several threads within the last week or so discussing this very thing.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Opening an excel file from a button. square brackets in filename

    Internet explorer 6. Apex 3.1
    When I open an excel file (via a button) , it has the filename as follows:
    production_report[1].csv
    The prompt to save or open has the name as production_report.csv
    This prevents people saving the opened file as square brackets are not allowed in the file name.
    Is this an apex issue (ie a problem with the way I specify the filename) or a browser issue, and is there a solution?
    I am passing the filename in to my excel download page using the items/values settings.
    eg
    ITEM P12_FILENAME
    ITEM VALUE production_report.csv

    Yes, It works on firefox. It is only an issue with Internet Explorer.
    However our web based application has to use IE and therefore when it calls apex it is in an IE browser.
    I am really just producing a csv file, and opening it in excel. If this was fixed (or customisable in some way in IE that would help)

  • Error in Open Excel Files from JSP..it display Eksponen...

    How to set Excel format in JSP? - Error in Eksponen.
    Hi, i have a problem.
    I am using JSP to select data from database and open it as an Excel file.
    It works perfectly, but the problem is,
    when the data is NUMBER (even though in JSP, i declare it as a String), in the Excel file, when the data is more than 10, the data will change to Eksponen value.
    Should be = 982520000324464
    but in Excel is = 9.8252E+14
    Can anybody help?

    Depending on how you are generating the Excel file there are different solutions.
    If you are generating the Excel file using contentType="application/vnd.ms-excel" and HTML tables, then you can use the following attribute on the cell you wish to format:
    <TD style="vnd.ms-excel.numberformat:#,##0;">24.562234</TD>where the #,##0 corresponds to the format you wish to present the data in.

  • Opening the Excel file from Application server

    Hi All,
    I had uploaded an excel file on the application server for using it in my program .
    But when i am opening the uploaded file on the Application server it shows some special characters and those are also displayed on my report output while reading the file from the application server.
    Please suggest how to get rid of those special characters.
    my open data set statement is
    OPEN DATASET pg_out2 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

    Hi ,
    if it a Excel file ..
    do the following..
        OPEN DATASET pg_out2              "appl file
                FOR INPUT IN TEXT MODE
                ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          DO.
            READ DATASET p_infile INTO w_temp.
    *       Condition To check when cursor reaches End Of file
            IF sy-subrc EQ 0.
              PERFORM f_split_appl_data.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
          CLOSE DATASET p_infile.
        ELSE.
          MESSAGE 'Error in opening file' type 'E'.
        ENDIF.
    FORM f_split_appl_data .
      SPLIT w_temp AT ',' INTO : wa_inputfile-plannum ......   "Split at , for excel or CSV file formats at appl files
      APPEND wa_inputfile TO t_inputfile.
    ENDFORM.                    " F_SPLIT_APPL_DATA
    Prabhudas

  • Opening an Excel file from a Website

    We have an .XLS file that our users open from an IIS 6.0 website.  A majority of our users can open the current version of the file.
    Some of our users get a cached version of the file from days ago when they click on the website's URL for the spreadsheet.  The Excel spreadsheet opens as [Read Only] [Shared] [Compatability Mode] for all of our users.  We have multiple users on
    the same PC and not all of the users have the same issue of opening a cached version.
    I have narrowed it down to something going on with the profile because I delete the profile of a user experiencing the issue and the current version of the spreadsheet opens.  This is a painful bandaid to fix the issue.
    I have found multiple copies of the spreadsheet in C:\users\<USERID>\appdata\Roaming\Microsoft\Excel   Is this where Excel stores copies of the spreadsheet when it downloads?  Is there a place in the profile that Excel stores offline
    copies of spreadsheets that are downloaded?
    I have thought about one of the following to resolve the issue:
    1.  Saving the master spreadsheet as HTML on the web site.  The problem is the webpage opens and transitoins to other "tabs" slower than the actual spreadsheet
    2.  Write a login\logoff script to clear out the location the cached file is stored.  I first have to make sure that I have the correct location.
    3.  Change settings in Excel or IE to clear out the cache that Excel is using.
    4.  Convert the Excel spreadsheet to an .XLSX file and update the URL on the website to reflect the new file
    Am I missing something or does anyone have another suggestion to resolve the issue?

    Hi,
    Please try the steps below and check if it helps:
    1. Search for "Upload Center" in your Windows.
    2. In the Upload Center window, click Settings.
    3. Tick the check box labelled "Delete files from the Office Document Cache when they are closed".
    4. Click "Delete cached files" button.
    5. Click OK.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Open a Local file from JSP

    Hi All,
    I want to access a local file from a JSP. On click of the link the local file should open. The location of the local file is
    O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc
    and the hyper link on the JSP shows
    file:///O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc
    somehow the file does not open from the JSP page but it opens from the browser if I type
    'file:///O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc' in the address bar.
    Can anybody please help.
    regards,
    Shardul.

    if you'd like to show the real path to the user, use simply an ftp server !
    however, if you prefer a secure solution, so use a servlet:
    example:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SendWord extends HttpServlet {
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        //get the 'file' parameter
        String fileName = (String) request.getParameter("file");
        if (fileName == null || fileName.equals(""))
          throw new ServletException(
              "Invalid or non-existent file parameter in SendWord servlet.");
        // add the .doc suffix if it doesn't already exist
        if (fileName.indexOf(".doc") == -1)
          fileName = fileName + ".doc";
        String wordDir = getServletContext().getInitParameter("word-dir");
        if (wordDir == null || wordDir.equals(""))
          throw new ServletException(
              "Invalid or non-existent wordDir context-param.");
        ServletOutputStream stream = null;
        BufferedInputStream buf = null;
        try {
          stream = response.getOutputStream();
          File doc = new File(wordDir + "/" + fileName);
          response.setContentType("application/msword");
          response.addHeader("Content-Disposition", "attachment; filename="
              + fileName);
          response.setContentLength((int) doc.length());
          FileInputStream input = new FileInputStream(doc);
          buf = new BufferedInputStream(input);
          int readBytes = 0;
          while ((readBytes = buf.read()) != -1)
            stream.write(readBytes);
        } catch (IOException ioe) {
          throw new ServletException(ioe.getMessage());
        } finally {
          if (stream != null)
            stream.close();
          if (buf != null)
            buf.close();
      public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        doGet(request, response);
    }hope that helps

  • Can I open a excel file from labview

    I have a program who write temperature in a excel file and i want to open this file from labview .

    This depends slightly on the amount of data you have stored within Excel.
    You can use the "Labview Functions>>FileIO>>Read from Spreadsheet file.vi" which effectively reads all lines from a text file and converts it into a numeric array.
    Alternatively, if your data structure in Excel is more complex than this, you can use ActiveX calls to Excel to retrieve it.
    Use an "ActiveX>>Automation Refnum" control and select the Excel server class. This will then enable you to access properties and methods of Excel to retrieve data from specific cells and pages.
    The attached example should help.
    Dan
    Attachments:
    Excel_Automation.vi ‏60 KB

  • Want to open a excel file from remote Linux server through ADF UI

    HI,
    My scenario is a excel template is located in LInux server in a directory. Then I need to download this excel file when I click on a hyperLink which will call the method mentioned below.
    however, below method works fine if the file is on windows machine/server but not if on Linux machine. In case of LInux it gives junk file.
    please suggest if any solution exists.
    Thanks,
    Sachin

    Moderator Action and Advice:
    @ user8106712,
    Your post has been split away from the completed 2006 thread you had resurrected.
    Hijacking someone else's discussion is poor forum etiquette.
    When you do that you are saying:
    "My issue is more important than yours. Ignore all that earlier stuff and just pay attention to me."
    If you want considerate responses, always start your own new post.
    You may also need to occasionally review the OTN Forums FAQ that is linked at the top corner of every page.

  • Opening Excel Files from DB (blob column)

    My project has implemented a WEBUTIL solution to attach files into the database, view the files stored in the database (in a BLOB column), and remove the files stored in the database.
    Everything has been running smoothly. We are in final testing and have found a couple of interesting scenarios ...
    When a user tries to view an Microsoft Excel 2007 file from our application, the Excel file displays properly (as long as Microsoft Excel isn't already open - outside of our Oracle application). Once the Excel file is viewed, the system will not allow the user back to our application until after the Excel file is closed (we use the start /wait myExcelFile.xls ... command). This works perfectly for us.
    The two scenarios we encounter occur when
    1.) The user has Microsoft Excel open outside of our application and tries to open an Excel file from within our application, or
    2.) The user has the file already open (either from within our application or outside of our application) and then tries to open the file from within our application.
    Let me explain a little further because the above two scenarios are interrelated.
    When a user has Microsoft Excel open (outside of our application), and then clicks the button to open the Excel file, the system will open the file as another window (within Excel). The system will allow the user to navigate back to our application (where as, if Excel is not open outside of our application, the system will not allow the user to navigate back to our application). Once the user navigates back to our application (while the file is still open), the user can click the button to view the file again. At this point, the user is displayed a WUT-105 error message (I assume b/c the system is trying to open a file that is already open).
    I assume the two solutions are the following:
    a.) Do not allow a user to open a file that is already open (not sure how to check this from within Forms ?)
    b.) Do not allow a user to open an Excel file when another EXCEL process is already running (this will avoid allowing the user to naviagate back to our application)
    I don't know if there is a better solution.
    Do you experts have any recommendations?
    We are using Oracle Application Server 10g R2 (10.1.2.0.2), Oracle Database 10g R2 (10.2), and Oracle Developer 10g (10.1.2.0.2)
    I hope this all makes sense.
    Thanks,
    Mike
    Edited by: user639843 on Oct 20, 2008 2:15 PM
    Edited by: user639843 on Oct 20, 2008 2:20 PM

    Thank you, Thank you, Thank you!!!!
    I believe that will work (adding a sequence number to the end of the filename)!
    We do not allow a user to update the file, only view. If a user wants to make a change, they need to remove the existing file (from the database), create a new file (outside of our application), and attach the file in our application (into the database). All updates occur outside of our application - we are not a document authoring system, just a document storage system.
    Once again, many thanks on the solution!
    Mike

Maybe you are looking for

  • Help.required.spaces&some.letters.'ot.worki'g

    please.help. as.you.ca.see.my.spaces.ad.the.letter.after.comig.after.m.i.the.alphabet.ist.wor kig.ad.some.others. ahhhhh i.tried.a.plug.i.keyboard.but.o.differece. i.have.a.imac

  • From Where MRM_XACCITCR_EXPORT is fetching the values in XACCIT in MIRO

    Hello all, I am debugging the MIRO transaction code in SAP, I want to know that from where does the function module MRM_XACCITCR_EXPORT fetches value in  XACCIT. i found that the table XACCIT is refreshed and has no records but o entering the functio

  • Unable to send keystrokes and Mouse strokes in during WinPE phase with iDRAC7

    Primary Site running SCCM 2012 R2 Unable to send keystrokes and Mouse strokes in during WinPE phase. The system is awaiting response "password" on Task Sequence step however the machine won't accept keyboard and mouse inputs. This happens with iDRAC7

  • How to know when File Adapter is complete when debatching?

    I have a BPEL process that reads in a file and debatches it into records of 1 and inserts them into a table. How do I know when the entire process is complete and all records in the file have been handled?

  • Bridge vs. Extend - advice?

    My current setup is an Actiontec router (Verizon FIOS) connected by ethernet to a TC that creates a wireless network. Upstairs I have two AE units that extend that same network. The current setup works OK, but the WiFi is sometimes slow. Both of the