乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      將Excel文件內(nèi)容寫入到數(shù)據(jù)庫(kù)

       昵稱2807 2006-10-12
      package  com.zhupan.spring;

      import  java.io.File;

      import  javax.servlet.http.HttpServletRequest;
      import  javax.servlet.http.HttpServletResponse;

      import  jxl.Sheet;
      import  jxl.Workbook;

      import  org.springframework.validation.BindException;
      import  org.springframework.web.multipart.MultipartFile;
      import  org.springframework.web.multipart.MultipartHttpServletRequest;
      import  org.springframework.web.servlet.ModelAndView;
      import  org.springframework.web.servlet.mvc.SimpleFormController;

      import  com.ctgusec.model.Student_info;
      import  com.ctgusec.service.IStudent_infoManage;

      /**
       * 
      @author  zhupan
       * 
       
      */

      public   class  EStudentInsertExcelController  extends  SimpleFormController  {

          
      private  IStudent_infoManage studentManage;

          @Override
          
      protected  ModelAndView onSubmit(HttpServletRequest request,
                  HttpServletResponse response, Object command, BindException errors)
                  
      throws  Exception  {
              Student_info student_info 
      =  (Student_info) command;
              
      try   {            
                  MultipartHttpServletRequest multipartRequest 
      =  (MultipartHttpServletRequest) request;
                  MultipartFile file 
      =  multipartRequest.getFile( " Excelfile " );  //  獲得文件:
                  File toFile  =   new  File( " c:\\學(xué)生信息臨時(shí)文件.xls " ); //  產(chǎn)生文件名和空文件
                  file.transferTo(toFile); //  文件上傳
                  Workbook book  =  Workbook.getWorkbook(toFile); // 得到工作薄            
                  Sheet sheet  =  book.getSheet( 0 ); //  獲得第一個(gè)工作表對(duì)象
                   int  row  =  sheet.getRows(); //  /得到該sheet的行數(shù)
                   int  column  =  sheet.getColumns();  //  得到該sheet的列數(shù)    
                  System.out.println( " 數(shù)據(jù)行數(shù)= " + row);
                  System.out.println(
      " 數(shù)據(jù)列數(shù)= " + column);
                  
      for ( int  i = 1 ;i < row;i ++ )
                  
      {
                      
      for ( int  j = 0 ;j < column;j ++ )
                      
      {
                          System.out.println(
      " j= " + j);
                          sheet.getCell(j, i).getContents();
      //  得到第j列第i行的單元格的類容        
                          student_info.setStudentID(sheet.getCell(j, i).getContents());    
                          student_info.setName(sheet.getCell(
      ++ j,i).getContents());    
                          student_info.setSex(sheet.getCell(
      ++ j,i).getContents());    
                          student_info.setUnit(sheet.getCell(
      ++ j,i).getContents());    
                          student_info.setClass_(sheet.getCell(
      ++ j,i).getContents());    
                          student_info.setSpecialty(sheet.getCell(
      ++ j,i).getContents());    
                          student_info.setRemark(sheet.getCell(
      ++ j,i).getContents());                        
                      }
          
                      
      if  ( this .studentManage.getStudentByStudentID(
                              student_info.getStudentID()).size() 
      !=   0 )
                          
      return   new  ModelAndView( " education/e-studentInfoAddError " );
                      
      this .studentManage.insertStudent_info(student_info);    
                  }
                      
                  book.close();
                  
      return   new  ModelAndView( " education/e-studentInfoAddExcelSuccess " , " row " , new  Integer(row - 1 ));
              }
        catch  (Exception e)  {                    
                  e.printStackTrace();
              }

              
      return   new  ModelAndView( " education/e-studentInfoAddExcelError " );
          }


          
      public   void  setStudentManage(IStudent_infoManage studentManage)  {
              
      this .studentManage  =  studentManage;
          }
          
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多