日期:2014-05-17 浏览次数:20695 次
private void importYdjksj(HttpServletRequest req, HttpServletResponse resp){
String status="0";
StringBuffer msg_err=new StringBuffer();
StringBuffer msg=new StringBuffer();
try {
YdjksjDao dao = new YdjksjDao();
String fileName = null; //导入文件名
int rowNum=0; //导入文件记录数
int rowNum_pre=3; //从前开始需要减的行数
int rowNum_last=1; //从后开始需要减的行数
int rowNum_start=4; //开始行数索引
int errNum=0;
String filePath="E:/tmp/import";
String filePath_new="";
filePath_new=generateFile(req, filePath, fileName);
Workbook wb = null;
try{
File file = new File(filePath_new);//(this.getHttpServletRequest().getParameter("sjwj"));
wb=Workbook.getWorkbook(file);
} catch (BiffException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(wb==null)
throw new Exception("文件对象为空!");
try {
Sheet[] sheet = wb.getSheets();
if(sheet!=null&&sheet.length>0){
rowNum = sheet[0].getRows();
String jkyh="";
String yhzh="";
String bsrq="";
jkyh=getSpeciBySplit(sheet[0].getRow(1), "dsyh:");
yhzh=getSpeciBySplit(sheet[0].getRow(1), "ylshdm:");
bsrq=getSpeciBySplit(sheet[0].getRow(2), "bbfsrq:");
System.out.println("jkyh:"+jkyh+", yhzh:"+yhzh+", bsrq:"+bsrq);
if (rowNum > rowNum_pre){
&nb