菜鸟也不怕,干it的会在百度里找到相对应的答案就可以。我指的是菜鸟阶段。我也是菜鸟。呵呵。
1,用jdbc或hibernate把数据读出来,这个是一定的。
2,操作excel主要可以用jxl这个jar包,导进去。用这个包的时候,几个主要的操作,
try {
//open file.
WritableWorkbook book = Workbook.createWorkbook(new File("d:/Test.xls"));
//create Sheet named "Sheet_1". 0 means this is 1st page.
WritableSheet sheet = book.createSheet("Sheet_1", 0);
//define cell column and row in Label Constructor, and cell content write "test".
//cell is 1st-Column,1st-Row. value is "test".
Label label = new Label(0, 0, "test");
//add defined cell above to sheet instance.
sheet.addCell(label);
//create cell using add numeric. WARN:necessarily use integrated package-path, otherwise will be throws path-error.
//cell is 2nd-Column, 1st-Row. value is 789.123.
jxl.write.Number number = new jxl.write.Number(1, 0, 789.123);
//add defined cell above to sheet instance.
sheet.addCell(number);
//add defined all cell above to case.
book.write();
//close file case.
book.close();
相关的操作,网上有好多。去搜一下。
温馨提示:答案为网友推荐,仅供参考