Java操作Excel、PDF文件(2)计算机等级考试
文章作者 100test 发表时间 2010:01:28 11:54:07
来源 100Test.Com百考试题网
wbook.write(). // 写入文件
wbook.close().
os.close().
return "success".
}
}
public class ExcelBean {
public String expordExcel(OutputStream os, List courseList,List studentList)
throws Exception {
WritableWorkbook wbook = Workbook.createWorkbook(os). // 建立excel文件
String tmptitle = "课程“" ((Course_info)courseList.get(0)).getCource_name() "”的选课学生列表". // 标题
WritableSheet wsheet = wbook.createSheet("第一页", 0). // sheet名称
// 设置excel标题
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 16,
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
Colour.BLACK).
WritableCellFormat wcfFC = new WritableCellFormat(wfont).
wsheet.addCell(new Label(1, 0, tmptitle, wcfFC)).
wfont = new jxl.write.WritableFont(WritableFont.ARIAL, 14,
WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
Colour.BLACK).
wcfFC = new WritableCellFormat(wfont).
// 开始生成主体内容
wsheet.addCell(new Label(0, 2, "课程名称")).
wsheet.addCell(new Label(1, 2, "学 号")).
.........
for(int i=3.i