
Once the excel from the following jsp is loaded to the broswer, how to add a button in the jsp to allow the user to update the excel?
thanks,
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="org.apache.poi.xssf.usermodel.XSSFSheet"%>
<%@page import="org.apache.poi.xssf.usermodel.XSSFWorkbook"%>
<%@page import="org.apache.poi.xssf.usermodel.XSSFRow"%>
<%@page import="org.apache.poi.xssf.usermodel.XSSFCell"%>
<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);
XSSFWorkbook wb = new XSSFWorkbook(fs);
for(int k = 0; k < wb.getNumberOfSheets(); k++){
int j=i+1;
XSSFSheet sheet = wb.getSheetAt(k);
int rows = sheet.getPhysicalNumberOfRows();
for(int r = 0; r < rows; r++){
XSSFRow row = sheet.getRow(r);
int cells = row.getPhysicalNumberOfCells();
out.write("<br>");
XSSFCell cell1 = row.getCell(a);
value1 = cell1.getStringCellValue();
XSSFCell cell2 = row.getCell(b);
value2 = cell2.getStringCellValue();
XSSFCell cell3 = row.getCell(c);
value3 = cell3.getStringCellValue();
XSSFCell 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>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.