
<%@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"%>
<%
short a=0;
short b=1;
short c=2;
short d=3;
int i=0;
String value1="", value2="",value3=" ", value4="";
//String filename ="C:\\Users\\hp\\Desktop\\Book1.xls";
String filename=request.getParameter("excel");
if (filename != null && !filename.equals("")) {
try{
FileInputStream fs =new FileInputStream(filename);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
int rows = sheet.getPhysicalNumberOfRows();
out.println(rows);
for (int r = 0; r < rows; r++){
HSSFRow row = sheet.getRow(r);
HSSFCell cell1 = row.getCell(0);
value1 = cell1.getStringCellValue();
out.println(value1);
}
}
catch(Exception e){
System.out.println(e);
}
}
%>
when i gave full path name i got excel data but when file uploading not getting the excel data
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.