Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet how to present the excel to the web browser in jsp

Have Programming Question? Ask it here!
 
 
 


mike wang
how to present the excel to the web browser in jsp
4 Answer(s)      3 years and 3 months ago
Posted in : JSP-Servlet


How to present the content of the newly created excel file in the following jsp to the web browser:

<%@ page import="java.io.InputStream" %>
<%@ page import="org.apache.poi.xssf.usermodel.XSSFSheet"%>
<%@ page import="org.apache.poi.xssf.usermodel.XSSFWorkbook"%>
<%@ page contentType="application/vnd.ms-excel" %>
<%@ page import="java.io.*" %>
<%
        try {
           XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet1 = wb.createSheet("TA");
    XSSFSheet sheet2 = wb.createSheet("TM");
   XSSFSheet sheet3 = wb.createSheet("XFA");
    XSSFSheet sheet4 = wb.createSheet("OTHERS");

    FileOutputStream fileOut = new FileOutputStream
("c:\\excel\\test.xlsx");
    wb.write(fileOut);
    fileOut.close();    

        } catch ( Exception ex ) {

        } 
%> 
}

Advertisement
View Answers

May 19, 2011 at 11:46 AM


<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<table border="1">
<%
  short a=0;
  short b=1;
  short c=2;
  short d=3;
  int i=0;
    String   value1="", value2="",value3=" ", value4="";
    String filename ="C:/hello.xls"; 
    if(filename != null && !filename.equals("")){
    try{
    FileInputStream fs =new FileInputStream(filename);
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    for(int k = 0; k < wb.getNumberOfSheets(); k++){
    int j=i+1;
    HSSFSheet sheet = wb.getSheetAt(k);
    int rows  = sheet.getPhysicalNumberOfRows();
    for(int r = 0; r < rows; r++){
    HSSFRow row   = sheet.getRow(r);
    int cells = row.getPhysicalNumberOfCells(); 
    out.write("<br>");
    HSSFCell cell1  = row.getCell(a);
      value1 = cell1.getStringCellValue();
    HSSFCell cell2  = row.getCell(b);
      value2 = cell2.getStringCellValue();
    HSSFCell cell3  = row.getCell(c);
      value3 = cell3.getStringCellValue();
    HSSFCell cell4  = row.getCell(d);
      value4 = cell4.getStringCellValue();
    %>
    <tr><td><%=value1%></td><td><%=value2%></td><td><%=value3%></td><td><%=value4%></td></tr>
    <%
    }
        i++;
    }
    }
    catch(Exception e){
    System.out.println(e);
    }
    }
    %>
    </table>


May 19, 2011 at 11:52 AM


Thanks for the answers, you are excellent! one more followup questions: May I add some user actions: such as update the cells then update the excel files. thanks so lot!

looking forward to your answers!



May 19, 2011 at 12:32 PM


does the solution to the original questions work for the excel with multiple sheets and complicated content:

for instance: the excel file looks like:

tree structure: value1----6 a1
a2 a3

sheet1 sheet2 sheet3 sheet4 button: update

after the user update the excell from the browser, how to allow the user to update the excel.



December 16, 2011 at 2:54 AM


Does anyone know how to add a browse upload functionally to this code? This code automatically does it and this is incorrect by my standards



Related Tutorials/Questions & Answers:
how to present the excel to the web browser in jsp
how to present the excel to the web browser in jsp  How to present the content of the newly created excel file in the following jsp to the web browser: <%@ page import="java.io.InputStream" %> <%@ page import
how to display the excel file in the web browser.
how to display the excel file in the web browser.  > %@ page.../vnd.ms-excel" > %> <%@ page import="java.io.*" %> <% >... FileOutputStream > ("c:\\excel\\aqtemplate.xlsx"); > wb.write
Advertisements
getting the excel path throuh web browser given from client(i.e thruogh .jsp)
getting the excel path throuh web browser given from client(i.e thruogh .jsp)  1)when client uploads the excel sheet through a .jsp page, 2)get that excel path from web browser and read the data from the excel and printing
How to export web page to excel using java or jsp or servlets
How to export web page to excel using java or jsp or servlets  Hi I am trying to export web page(jsp page ) to excel using jsp or servlets. I am... errors. Please can anyone tell me how to do this using java or jsp or servlets
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying... status - 404. How can i resolve it in JSP
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
how to display the excel file content in the jsp
how to display the excel file content in the jsp  How to present the content of the newly created excel file in the following jsp to the web browser...="application/vnd.ms-excel" %> <%@ page import="java.io.*" %> <
PHP Open Excel File in browser - PHP
PHP Open Excel File in browser  How we can open an excel file using PHP code. I don?t want to let the user to download it rather I would like to get it open in the web browser. Any help would be great. Thank you very much
How to export chart(graph) generated by jsp into a excel?
How to export chart(graph) generated by jsp into a excel?  How to export chart(graph) generated by jsp into a excel? I have a jsp page which generates charts . Now I need those charts to be exported into an excel.please help
how to create a jave version excel in jsp
how to create a jave version excel in jsp  I would like to create a java version excel in JSP. so the excel like document can be published in the internet. the user will be able to enter the information and click the save button
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
JSP TO EXCEL
JSP TO EXCEL  Hi sir/mam, How to import data to excel using jsp without retrieving database.   friend, you can't import excel data into the middle of an HTML pages (your JSP will result in an HTML page
How to disable browser back and forward button after logout [in struts2 or jsp]
How to disable browser back and forward button after logout [in struts2 or jsp]  How to disable browser back and forward button after logout [in struts2 or jsp] I am using window.history.forward(); function
how to create web page on jsp?
how to create web page on jsp?  how to create web page on jsp
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
How to download web page table data, export the table records in an excel file and save
How to download web page table data, export the table records in an excel file and save  i have a web page(.jsp) which contains the table of 4 to 5 columns. i m displaying the table using in my jsp page. below this table i want
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each column values from that large excel file.For small file i am getting values
Java Web Browser Problem
Java Web Browser Problem  Hello When run my web browser this is not displaying complete page any of the website like other browser.So Plz help me...."); setTitle("NextVision Browser"); setSize(600,400); Container
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  Dear All I created JSP.... Anyone having idea how to disable browser back button after logout, please... problem is, when i am clicking browser back button i can see my old visited pages
how to disable back button of a browser after logging in? - JSP-Servlet
how to disable back button of a browser after logging in?  how to disable back button of a browser after logging in?  where is the source code
JSP to Excel - JSP-Servlet
JSP to Excel  Need an example of JSP and Excel database connection. Thanks
jsp excel code - JSP-Servlet
jsp excel code  hi how to store html form data into excel sheet by using jsp? and repeat this process continuously for entire sheet
how to read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare with database using jsp coding i.e, if i have 6(assetid,assetname,serialno,cubical
Function data from web in MS excel
data from one webpage to Excel using function Data - From Web. The problem is that this web page has at the end .jsp . When I open it via Excel, click to data... believe that the reason is format of .jsp because another web pages are working
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  thanks deepak, i tried but if i am clicking back still i can see my old pages. i copied your code in my logout page. please if you have any other solution, please give me
jsp to excel - JSP-Servlet
jsp to excel  Hi All, I'm writing a program of jsp to Excel conversion with Using POI. My problem is i'm unable to put multiple data into excel...)); } FileOutputStream fileOut = new FileOutputStream("c:\\excel\\wct.xls
difference from browser to browser - JSP-Servlet
difference from browser to browser  I am developing a project in jsp. When browse in mozilla it works good and when I open it with IE there is a difference how to overcome this problem.Thanks in advance
Excel - JSP-Servlet
Excel  How to export data from jsp to excel sheet. I am using struts1.2 in my application.  Hi friend, Code to data from Jsp to excel...: "success.jsp" For more information on excel sheet Using JSP visit
jsp data in excel - JSP-Servlet
jsp data in excel  i have create jsp page which has button for excel.this calls jsp which contains code which has and then code for present data... and this query data has come from beans and using beans i put it in excel jsp in table
how to disable browser back button
how to disable browser back button  Am doing a web application in that how to disable browser back button using java script
jsp excel code - JSP-Servlet
jsp excel code  Hi how to insert form data into excel file using jsp?  Hi Friend, Try the following code: 1)register.jsp: Registration Form First Name: Last Name: User Name: Password
Top 10 Web Trends of Present Time
the most dominating present day web trends is quite a task since the it requires so... a look at our picks on top 10 web trends of present time. Niche social network... the present day web trends Big Data holds the greatest potential to change the way we
How to Unlock Excel Password
How to Unlock Excel Password  anyone help me how to recover lost Excel file password
How to print contents of a web page in jsp?
How to print contents of a web page in jsp?  I have generated a pay slip using jsp.How do I print the contents of the slip
how to communicate with different web applications - JSP-Servlet
how to communicate with different web applications  how to communicate with different web applications which are under same or different servers? ex... to second/jsp/show.jsp without using query string like that can u guide me how
browser - JSP-Servlet
browser  Browser buttons In a website program with login and session concept, logout option is working properly in JSP pages. While pressing directly the back and front buttons in browser [Internet Explorer 6.0
files that are present in any folder , how to make it clickable downloadble file in php
files that are present in any folder , how to make it clickable downloadble file in php   files that are present in any folder , how to make it clickable downloadble file in php
Jsp to Excel
Jsp to Excel          In this section you will learn how to create an excel file and write data into it using jsp. For this, you have to import
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
How to communicate with different web applications ? ? ? ? - JSP-Servlet
How to communicate with different web applications ? ? ? ?  How to communicate with different web applications which are under same or different... to second/jsp/show.jsp without using query string like that can u guide me how
How to communicate with different web applications ? ? ? ? - JSP-Servlet
How to communicate with different web applications ? ? ? ?  Deepak ji thanks for fast reply still i have some doubt about this How to communicate with different web applications which are under same or different servers? ex
* How to communicate with different web applications ? ? ? ? - JSP-Servlet
* How to communicate with different web applications ? ? ? ?  Deepak ji thanks for fast reply still i have some doubt about this How to communicate with different web applications which are under same or different servers? ex
*** How to communicate with different web applications ? ? ? ? - JSP-Servlet
*** How to communicate with different web applications ? ? ? ?  Deepak ji thanks for fast reply still i have some doubt about this How to communicate with different web applications which are under same or different servers? ex
excel uploading in jsp
excel uploading in jsp  could you provide the source code for: 1)have to upload an empty excel sheet at client side i.e if client clicks an excel icon an empty excel sheet should open 2)when they fill data in that sheet and click
jsp - excel generating problem - JSP-Servlet
jsp - excel generating problem  Hi, I worked with the creating excel through jsp, which is the first example in this tutorial...://www.roseindia.net/jsp/poi/generatingExcelSheet.shtml In this page create excel sheet
How to get browser time zone?
How to get browser time zone?  How to get browser Time Zone and browser date using java concept
How to insert rows from Excel spreadsheet into database by browsing the excel file?
the excel file using file browsing dialogue through form in JSP. How can i select excel file and insert rows into MSSQL database in JSP???   Have a look...How to insert rows from Excel spreadsheet into database by browsing the excel
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
how to capture IE browser FileDownload box open ,save and cancel event - JSP-Servlet
how to capture IE browser FileDownload box open ,save and cancel event  I have a JSP page which allows user to download a file.When user click... in response object.B/C of this ,browser fileDownload dialog box comes.we need
 

 

 

DMCA.com