HSSFCell pcell1 = row.createCell((short)1); pcell1.setEncoding(HSSFCell.ENCODING_UTF_16); pcell1.setCellValue("学科"); ScorePrint scorrec =null; ScoreRecordDAO scorerecDAO= new ScoreRecordDA(); ArrayList list = null; try{ list =scorerecDAO.findAllScoreByCourse(101001);
for(int i=0;i<list.size();i++) { HSSFRow rowrec = sheet.createRow((short)(i+1)); // Create a cell and put a value in it. HSSFCell cell0 = rowrec.createCell((short)0); cell0.setEncoding(HSSFCell.ENCODING_UTF_16); cell0.setCellValue("姜咏");
HSSFCell cell1 = rowrec.createCell((short)1); cell1.setEncoding(HSSFCell.ENCODING_UTF_16); cell1.setCellValue("英语"); } catch (Exception e) {} // Write the output to a file FileOutputStream fileOut = new FileOutputStream("成绩单.xls"); System.out.println("Insert Excel"); wb.write(fileOut); fileOut.close();你看看吧,我现在正在用,挺好使得!!!
这里看看有没有帮助。
我现在已经用Servlet输出了一个嵌入了excel表的html页面。但是我还不知道如何把页面上的数据导入到打开的这个excel表中。希望你多多帮助!
to AngusZhang(zhgapp)你好,我看过上面的网站内容,down下来的资料多是些子函数;我现在任务比较急,我想以后会仔细看的。
谢谢上面二位。
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short)0);
HSSFCell pcell0 = row.createCell((short)0);
pcell0.setEncoding(HSSFCell.ENCODING_UTF_16);
pcell0.setCellValue("学生姓名");
HSSFCell pcell1 = row.createCell((short)1);
pcell1.setEncoding(HSSFCell.ENCODING_UTF_16);
pcell1.setCellValue("学科"); ScorePrint scorrec =null;
ScoreRecordDAO scorerecDAO= new ScoreRecordDA();
ArrayList list = null;
try{
list =scorerecDAO.findAllScoreByCourse(101001);
for(int i=0;i<list.size();i++)
{
HSSFRow rowrec = sheet.createRow((short)(i+1));
// Create a cell and put a value in it.
HSSFCell cell0 = rowrec.createCell((short)0);
cell0.setEncoding(HSSFCell.ENCODING_UTF_16);
cell0.setCellValue("姜咏");
HSSFCell cell1 = rowrec.createCell((short)1);
cell1.setEncoding(HSSFCell.ENCODING_UTF_16);
cell1.setCellValue("英语");
}
catch (Exception e) {}
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("成绩单.xls");
System.out.println("Insert Excel");
wb.write(fileOut);
fileOut.close();你看看吧,我现在正在用,挺好使得!!!