2013-07-25 72 views
-1

如何選擇我知道紙張名稱的現有紙張?我想將代碼追加到工作表中,但在不同的列中。在下面的代碼中,我指的是wb.creatsheet(「摘要」)行。選擇現有紙張

def sql_a = """ 

SELECT MOPACTIVITY.MOPID FROM MOPUSER.MOPACTIVITY WHERE UPPER(MOPACTIVITY.mopid) = 'JONATHAN MORNINGSTAR' 
ORDER BY MOPACTIVITY.MOPID 

    """ 

def date = new Date() 
def dts = date.format("yyyy-MM-dd-HH-mm-ss") 
File file = new File('X:/CCG/' + dts + ' CCG REPORT.xls')    
file.write("") 

Workbook wb = new HSSFWorkbook() 

try { 
    Sheet sheet = wb.createSheet("Summary") 
       sheet.setColumnWidth(0,8.43 * 256) 
       int rowNum = 0 

    Row row = sheet.createRow(rowNum) 
    Cell cellMOPID = row.createCell(0) 

       cellMOPID.setCellStyle(headerStyle) 

       cellMOPID.setCellValue("") 

       db.eachRow(sql_a) { 

           rowNum++ 
           row = sheet.createRow(rowNum) 
           cellMOPID = row.createCell(0) 

           cellMOPID.setCellValue(it.MOPID) 

           file.append(it.MOPID + "\n") 
       } 

} catch (Exception e) { System.out.println(e.toString()) } 

回答

相關問題