如何选择我知道工作表名称的现有工作表?我想将代码附加到工作表但在不同的列中。在下面的代码中,我指的是 wb.creatsheet("Summary") 行。
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()) }