Answer the question
In order to leave comments, you need to log in
Why is it not loading from *.xlsx (Apache POI)?
Hello.
I'm trying to load information from an excel file (*.xlsx) to JSP using Apache POI (3.15)
Information in C:\\server\\to_db.xlsx looks like this:
num solution
1 First
2 Second
3 Third
<%
try {
InputStream ExcelFileToRead = new FileInputStream("C:\\server\\to_db.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFWorkbook test = new XSSFWorkbook();
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row;
XSSFCell cell;
Iterator rows = sheet.rowIterator();
while (rows.hasNext()) {
row = (XSSFRow) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
cell = (XSSFCell) cells.next();
if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
out.print(cell.getStringCellValue() + " ");
} else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
out.print(cell.getNumericCellValue() + " ");
} else {
//U Can Handel Boolean, Formula, Errors
}
}
out.println("Succefully!!!");
}
}
catch (Exception e) {
out.println( "exception: "+e);
}
%>
Answer the question
In order to leave comments, you need to log in
added commons files and everything worked
it would be nice if some error was returned in this case....
Hello.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question