posts - 5,  comments - 7,  trackbacks - 0
/**   
        *   給料統計Excelファイル書く   
        *   
@param   fileName   folderName+fileName   
        *   
@param   value   List   
        *   
@throws   IOException   
        
*/
   
      
public   static   void   writeSalaryExcelFile(String   fileName,   List   value,   String   data,   String   deptName)   throws   
      IOException
{   
      PayRecordForm   countResultForm   
=   null;   
      InputStream   inputFile   
=   null;   
      FileOutputStream   fOut   
=   null;   
      HSSFWorkbook   wb   
=   null;   
      
try   {   
      
                  inputFile   
=   new   FileInputStream(fileName);   
                  
//workbook作成   
                  wb   =   new   HSSFWorkbook(inputFile);   
                    
                  
//sheet作成   
                  HSSFSheet   sheet   =   wb.getSheetAt(0);   
                  
//wb.setSheetName(0,   "DataCount");   
                  HSSFRow   row   =   null;   
                  HSSFCell   cell   
=   null;   
                  
//準備完了   
      
                  SalaryPropertyRead   prop   
=   new   SalaryPropertyRead();   
                  
short   rowStart   =   OutBean.formatShort(prop.getProperty("start"));   
                  
short   spanRow   =   OutBean.formatShort(prop.getProperty("rows"));   
                  String   str   
=   "";   
                  String[]   postion   
=   null;   
                    
                  HSSFRow   tempRow   
=   null;   
                  
//表数据   
                  int   size   =   value.size();   
                  
int   currentRow   =   rowStart;   
                  
for   (int   mIndex   =   0;   mIndex   <   size   ;   mIndex++)   {   
                  countResultForm   
=   (PayRecordForm)value.get(mIndex);   
                  currentRow   
=   rowStart+spanRow*mIndex;   
                  row   
=   sheet.getRow(currentRow);       
                  
if(row   ==   null){   
                  row   
=   sheet.createRow(currentRow);   
                  }
   
                    
                  
//名前   
                  setSalaryRow(sheet,row,prop.getProperty("employeeName"),currentRow,countResultForm.getEmployeeName());   
                  str   
=   prop.getProperty("employeeName");   
                                                            
                          
//日数     
                  setSalaryRow(sheet,row,prop.getProperty("workDays"),currentRow,countResultForm.getWorkDays());   
                                            
                          
//出勤日数   
                  setSalaryRow(sheet,row,prop.getProperty("currentDays"),currentRow,countResultForm.getCurrentDays());   
                                            
                          
//缺勤日数   
                  setSalaryRow(sheet,row,prop.getProperty("noWorkDays"),currentRow,countResultForm.getNoWorkDays());   
                                            
                          
//遅刻回数   
                  setSalaryRow(sheet,row,prop.getProperty("lateDays"),currentRow,countResultForm.getLateDays());   
                                            
                          
//早退回数   
                  setSalaryRow(sheet,row,prop.getProperty("exitEarlyDays"),currentRow,countResultForm.getExitEarlyDays());   
                                    
                          
//残業週末時間           
                  setSalaryRow(sheet,row,prop.getProperty("weekDays"),currentRow,countResultForm.getWeekDays());   
                                            
                          
//有給休暇日数         
                  setSalaryRow(sheet,row,prop.getProperty("payAppDays"),currentRow,countResultForm.getPayAppDays());   
                                          
                          
//まきの休暇を取る日数がない       
                  setSalaryRow(sheet,row,prop.getProperty("noPayAppDays"),currentRow,countResultForm.getNoPayAppDays());   
                                                    
                          
//基本給料       
                  setSalaryRow(sheet,row,prop.getProperty("base"),currentRow,countResultForm.getBase());   
                                                  
                          
//全勤給料     
                  setSalaryRow(sheet,row,prop.getProperty("allPay"),currentRow,countResultForm.getAllPay());   
                                                    
                          
//保険金額                           
                          setSalaryRow(sheet,row,prop.getProperty("insurance"),currentRow,countResultForm.getInsurance());   
                    
                  }
               
                  
//入力完了   
    
                  
//新規出力文件流   
                  fOut   =   new   FileOutputStream(fileName);   
                  
//   保存する。   
                  wb.write(fOut);   
                  fOut.flush();   
                  
//作成完了、ファイルを閉じる。                 
                  System.out.println("ファイル作成完了!");   
    
              }
   
              
catch   (Exception   e)   {   
              e.printStackTrace();   
                  System.out.println(
"   xlCreate()   :   "   +   e);   
              }
   finally   {   
              
try{   
              wb   
=   null;   
              
if(fOut   !=   null){   
              fOut.close();   
              }
   
              
if(inputFile   !=   null){   
              inputFile.close();   
              }
   
              }
   catch   (Exception   e){               
              }
   
              }
   
      }
   
posted on 2008-11-29 10:04 Vincent-chen 阅读(390) 评论(0)  编辑  收藏 所属分类: POI

只有注册用户登录后才能发表评论。


网站导航: