poi操作excel动态创建多个sheet

public  static  void  main(String[] args)  throws  IOException {
         FileInputStream fileinput =  new  FileInputStream( "c:\\datarevised1.xls" );
         POIFSFileSystem fs =  new  POIFSFileSystem(fileinput);
         HSSFWorkbook wbinput =  new  HSSFWorkbook(fs);
         // --------------------------------------------------------------
         fileinput.close();
         HSSFWorkbook wboutput =  new  HSSFWorkbook();
         for  ( int  m =  0 ; m <=  20 ; m++) {
              
             HSSFSheet sheetoutput = wboutput.createSheet();
             wboutput.setSheetName(m,  "Datarude"  + String.valueOf(m));
  
             HSSFSheet sheetinput = wbinput.getSheetAt( 0 );
  
             HSSFRow rowinput;
             String cell; // String cell;
             // 循环输出表格中的内容
             for  ( int  i = sheetinput.getFirstRowNum(); i < sheetinput.getPhysicalNumberOfRows(); i++) {
                 //基本读写操作                }
  
             }
  
             FileOutputStream fileoutput =  new  FileOutputStream( "c:\\new1.xls" );
             wboutput.write(fileoutput);
             fileoutput.close();
         }
     }
                                                    
                                             如有疑问请邮箱至[email protected] QQ:858084865
 

你可能感兴趣的:(JAVA专区)