基础篇
package bankfenxi;
import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class jxlReadExcel {
public static void main(String[] args) {
try {
//创建workbook
Workbook workbook=Workbook.getWorkbook(new File("F:\\excel\\平安银行对账单.xls"));
//获取sheet页
Sheet sheet=workbook.getSheet(0);
//获取数据
for(int i=0;i<sheet.getRows();i++){
for(int j=0;j<sheet.getColumns();j++){
Cell cell=sheet.getCell(j,i);
System.out.print(cell.getContents()+"\t");
}
System.out.println();
}
workbook.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
——————————————————————————————————————————————
晋级篇
package com.it.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class servletbiao extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username1=request.getParameter("username");
String password2=request.getParameter("password");
excle excel=new excle();
Map<String, String> map = excel.readxls();
for (String key : map.keySet()) {
if(username1.equals(key)&&password2.equals(map.get(key))){
System.out.println("sssssssss");
//
request.getRequestDispatcher(/1.jsp).foward(request,response);
response.sendRedirect("s/1.jsp");
}else{
System.out.println("ssssssssssssssssssssssss");
}
//
System.out.println("key= "+ key + " and value= " + map.get(key));
}
response.sendRedirect("login.jsp");
}
protected void doPost(HttpServletRequest request1, HttpServletResponse response) throws ServletException, IOException {
doGet(request1, response);
}
}