Opening Excel file in Browser

Discussions

Web tier: servlets, JSP, Web frameworks: Opening Excel file in Browser

  1. Opening Excel file in Browser (8 messages)

    Hi,
    I am trying to open excel file in server path web app folder to browser, But i get junk values printed on the web side.Kindly help me with code to resolve this problem i am using JSP and javascript to open the file.

    Threaded Messages (8)

  2. excel in browser[ Go to top ]

    response.setContentType("application/vnd.ms-excel");

    Try that before any writing any output.
  3. excel in browser[ Go to top ]

    a href="../board/upload/< %=rs.getString(11)% >" target="new", img src="../images/img_99840.gif" border="0" , /a

    Is the code i am using in JSP to open the excel file from the web app folder to client browser.

    As this new window is instance and it is not a source coded jsp page i can not include any setHeader.If there is a better way that i can deal from the above code kindly help me out with that.
  4. excel in browser[ Go to top ]

    Try adding "application/vnd.ms-excel" as a MIME type for your server, associated with the ".xls" file extension.

    You can do this using server-specific configuration, or by adding the MIME type to your web.xml configuration:

    <mime-mapping>
      <extension>xls</extension>
      <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
  5. excel in browser[ Go to top ]

    Use the following code u can open excel file .
     

    File filepath=new File(file.xls);

    resp.setContentType("application/vnd.ms-excel");
    resp.setHeader("Content-Disposition","inline; filename=" + filepath);

    A href='<%=filepath%>' target="_blank">
    <image src="/UploadAppWeb/resources/images/download.gif" border="0" />
                                                                 </A
  6. excel in browser[ Go to top ]

    This code works fine when you open the excel sheet from the diaolg box. But when you save it to the file and open it again from open,save dialog box the image is not showing up. However if you save it once you open it is showing up the image. Does anybody has any idea how to fix this. Here is the code that I have.

       response.setContentType("application/vnd.ms-excel ");
          fileName = sample + ".xls";
       response.setHeader("Content-disposition",
                      "inline; filename=" + fileName );

          a href='<%=fileName%>' target="_blank">
              <img src="./mapRequestor.jsp?url=<%=URLEncoder.encode(mapURL.replaceTokens(tokens))%>" border="0" />
           </a

    Note: If I use "attachment" in place of "inline" the image is not showing up at all.
  7. excel in browser[ Go to top ]

    Hi eswar Kumar
            I use your code to open excel file,but not open excel I get only empty excel Please help me

    Nagesh...

    File filepath=new File(file.xls);

    resp.setContentType("application/vnd.ms-excel");
    resp.setHeader("Content-Disposition","inline; filename=" + filepath);

    A href='<%=filepath%>' target="_blank">
    <image src="/UploadAppWeb/resources/images/download.gif" border="0" />
                                                                 </A
  8. excel in browser[ Go to top ]

    hi,

     

    i have used in the same way in Web.xml, but its of no use.Could you plz suggest wt can be done.

  9. office[ Go to top ]

    codes or office web site is better to provide such a service ??